:root {
  --paper: #f5f4f1;
  --surface: #ffffff;
  --ink: #202126;
  --muted: #777a82;
  --line: #e4e3de;
  --soft: #efeee9;
  --violet: #6658d9;
  --violet-soft: #efedff;
  --green: #238660;
  --amber: #b7781d;
  --red: #bd4c49;
  --sidebar: 220px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.login-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(330px, 1.05fr) minmax(430px, .95fr); background: #202126; }
.login-brand { position: relative; display: flex; flex-direction: column; justify-content: space-between; min-height: 100vh; padding: clamp(38px, 7vw, 86px); color: white; overflow: hidden; }
.login-brand::after { content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%; right: -260px; bottom: -260px; background: #786ee0; opacity: .42; }
.login-wordmark { position: relative; z-index: 1; font-size: 25px; letter-spacing: -.05em; }
.login-brand h1 { position: relative; z-index: 1; margin: auto 0 20px; max-width: 620px; font-size: clamp(48px, 7vw, 88px); line-height: .95; letter-spacing: -.075em; }
.login-brand p { position: relative; z-index: 1; max-width: 440px; margin: 0; color: #c6c7cd; font-size: 15px; line-height: 1.7; }
.login-panel { min-height: 100vh; display: grid; place-items: center; padding: 34px; background: var(--paper); }
.login-card { width: min(390px, 100%); display: grid; gap: 18px; }
.login-card-brand { display: none; font-size: 22px; letter-spacing: -.05em; }
.login-card h2 { margin: 22px 0 8px; font-size: 36px; letter-spacing: -.055em; }
.login-card label, .dialog-card label { display: grid; gap: 8px; color: #555860; font-size: 11px; font-weight: 700; }
.login-card input, .dialog-card input, .dialog-card select, .dialog-card textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--ink); padding: 12px 13px; outline: none;
}
.login-card input:focus, .dialog-card input:focus, .dialog-card select:focus, .dialog-card textarea:focus { border-color: #aaa3ec; box-shadow: 0 0 0 3px var(--violet-soft); }
.form-error { min-height: 18px; margin: 0; color: var(--red); font-size: 11px; }
.muted { color: var(--muted); }

.app-layout { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: var(--sidebar); display: flex; flex-direction: column; background: #202126; color: white; }
.sidebar-brand { height: 78px; display: flex; align-items: center; padding: 0 23px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-brand strong { font-size: 22px; letter-spacing: -.055em; }
.sidebar nav { flex: 1; padding: 18px 11px; overflow-y: auto; }
.nav-group { display: grid; gap: 3px; padding: 0 0 14px; margin-bottom: 11px; border-bottom: 1px solid rgba(255,255,255,.07); }
.nav-group:last-child { border-bottom: 0; }
.nav-item { width: 100%; min-height: 39px; border: 0; border-radius: 8px; padding: 0 12px; background: transparent; color: #aaaeb6; text-align: left; font-size: 12px; font-weight: 560; cursor: pointer; transition: background .15s, color .15s; }
.nav-item:hover { color: white; background: rgba(255,255,255,.06); }
.nav-item.active { color: white; background: rgba(255,255,255,.11); }
.sidebar-footer { min-height: 76px; display: flex; align-items: center; gap: 10px; padding: 15px 16px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-footer > div { min-width: 0; flex: 1; }
.sidebar-footer strong, .sidebar-footer span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer strong { font-size: 10px; }
.sidebar-footer span { margin-top: 4px; color: #858990; font-size: 8px; }
.sidebar-footer button { border: 0; background: transparent; color: #a7aab1; font-size: 9px; cursor: pointer; }
.sidebar-backdrop { display: none; }

.workspace { min-height: 100vh; margin-left: var(--sidebar); }
.topbar { position: sticky; top: 0; z-index: 25; height: 78px; display: flex; align-items: center; gap: 18px; padding: 0 34px; background: rgba(245,244,241,.92); border-bottom: 1px solid var(--line); backdrop-filter: blur(16px); }
.topbar h1 { margin: 0; flex: 1; font-size: 20px; letter-spacing: -.04em; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.mobile-menu { display: none; border: 0; background: transparent; font-size: 10px; font-weight: 750; cursor: pointer; }
.primary-button, .secondary-button, .small-button, .text-button { border: 0; cursor: pointer; }
.primary-button { min-height: 42px; border-radius: 9px; padding: 0 17px; background: #202126; color: white; font-size: 11px; font-weight: 750; }
.primary-button:hover { background: #313339; }
.primary-button.compact { min-height: 36px; padding: 0 14px; font-size: 10px; }
.secondary-button { min-height: 40px; border: 1px solid var(--line); border-radius: 9px; padding: 0 14px; background: white; font-size: 10px; font-weight: 700; }
.text-button { background: transparent; color: var(--violet); font-size: 10px; font-weight: 700; }
.top-refresh { color: var(--muted); }

#content { max-width: 1480px; margin: 0 auto; padding: 32px 34px 56px; }
.loading-card, .empty-state { border: 1px solid var(--line); border-radius: 14px; padding: 44px 24px; background: white; color: var(--muted); text-align: center; font-size: 11px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 15px; }
.metric-card { position: relative; min-height: 132px; overflow: hidden; border: 1px solid var(--line); border-radius: 15px; padding: 18px 19px; background: white; }
.metric-card::after { content: ""; position: absolute; right: -36px; bottom: -60px; width: 120px; height: 120px; border-radius: 50%; background: #d8d3ff; opacity: .38; }
.metric-card:nth-child(3)::after { background: #c8ecdd; }
.metric-card:nth-child(4)::after { background: #ffe0ad; }
.metric-card span, .metric-card strong, .metric-card em { position: relative; z-index: 1; display: block; }
.metric-card span { color: var(--muted); font-size: 10px; }
.metric-card strong { margin: 17px 0 4px; font-size: 32px; line-height: 1; letter-spacing: -.045em; }
.metric-card em { color: #96989e; font-size: 9px; font-style: normal; }
.content-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 15px; }
.panel, .table-wrap, .toolbar, .notice-card, .section-head, .settings-shell { border: 1px solid var(--line); background: white; }
.panel { min-height: 340px; border-radius: 16px; overflow: hidden; }
.panel-header { min-height: 67px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 20px; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 0; font-size: 15px; letter-spacing: -.025em; }
.list-row { min-height: 63px; display: flex; align-items: center; gap: 12px; padding: 11px 20px; border-bottom: 1px solid #efeee9; }
.list-row:last-child { border-bottom: 0; }
.list-row > div { flex: 1; min-width: 0; }
.list-row strong, .list-row span { display: block; }
.list-row strong { font-size: 11px; }
.list-row span { margin-top: 5px; color: var(--muted); font-size: 9px; }
.badge { border-radius: 999px; padding: 5px 8px; background: var(--soft); color: #62656d !important; font-size: 8px !important; }

.toolbar { min-height: 68px; display: flex; align-items: center; padding: 13px 16px; border-radius: 15px 15px 0 0; border-bottom: 0; }
.search-box { width: min(420px, 100%); }
.search-box input { width: 100%; height: 39px; border: 1px solid var(--line); border-radius: 9px; background: #fafaf8; padding: 0 13px; outline: none; font-size: 11px; }
.search-box input:focus { border-color: #b3adeb; background: white; box-shadow: 0 0 0 3px var(--violet-soft); }
.table-wrap { overflow-x: auto; border-radius: 0 0 15px 15px; }
.toolbar + .table-wrap { border-top: 0; }
.data-table { width: 100%; min-width: 760px; border-collapse: collapse; }
.data-table th { padding: 13px 17px; background: #fafaf8; border-bottom: 1px solid var(--line); color: #8a8c92; font-size: 8px; letter-spacing: .075em; text-align: left; text-transform: uppercase; }
.data-table td { padding: 15px 17px; border-bottom: 1px solid #efeee9; color: #62656c; font-size: 10px; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fcfcfa; }
.data-table td strong, .data-table td small { display: block; }
.data-table td strong { color: var(--ink); font-size: 10px; }
.data-table td small { margin-top: 5px; color: #96989e; font-size: 8px; }
.row-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.small-button { min-height: 28px; border: 1px solid var(--line); border-radius: 7px; padding: 0 9px; background: white; color: #696b72; font-size: 8px; font-weight: 700; }
.small-button:hover { border-color: #c3bdec; color: var(--violet); }
.status { display: inline-flex; align-items: center; min-height: 23px; border-radius: 999px; padding: 0 8px; background: var(--soft); color: #666970; font-size: 8px; font-weight: 700; white-space: nowrap; }
.status.active, .status.done, .status.processed { background: #e6f4ed; color: var(--green); }
.status.pending, .status.high, .status.urgent, .status.in-progress { background: #fff3df; color: var(--amber); }
.status.canceled, .status.archived, .status.ignored { background: #f8e9e8; color: var(--red); }

.notice-card { display: grid; grid-template-columns: 1fr 170px; gap: 18px; margin-bottom: 12px; padding: 20px; border-radius: 14px; }
.notice-card h3 { margin: 0 0 9px; font-size: 13px; }
.notice-card p { max-width: 860px; margin: 0 0 16px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.notice-meta { color: var(--muted); font-size: 9px; line-height: 1.9; text-align: right; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 0; padding: 20px; border-radius: 15px 15px 0 0; border-bottom: 0; }
.section-head h2 { margin: 0; font-size: 15px; }
.section-head p { margin: 7px 0 0; color: var(--muted); font-size: 9px; }
.finance-total { margin-top: 5px; font-size: 24px; font-weight: 800; letter-spacing: -.04em; }
.section-head + .table-wrap { border-radius: 0 0 15px 15px; }

.settings-shell { display: grid; grid-template-columns: 230px 1fr; min-height: 590px; border-radius: 15px; overflow: hidden; }
.settings-menu { padding: 13px 10px; background: #fafaf8; border-right: 1px solid var(--line); }
.settings-menu-group { margin-bottom: 14px; }
.settings-menu-group h3 { margin: 11px 10px 7px; color: #96989e; font-size: 8px; letter-spacing: .08em; text-transform: uppercase; }
.settings-menu-item { width: 100%; min-height: 36px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; border: 0; border-radius: 8px; padding: 0 10px; background: transparent; color: #686b72; text-align: left; font-size: 9px; cursor: pointer; }
.settings-menu-item:hover, .settings-menu-item.active { background: white; color: var(--ink); }
.settings-menu-item em { min-width: 20px; border-radius: 5px; padding: 3px 5px; background: var(--soft); color: #8c8e94; font-size: 7px; font-style: normal; text-align: center; }
.settings-menu-icon { display: none !important; }
.settings-content { min-width: 0; }
.settings-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 20px; border-bottom: 1px solid var(--line); }
.settings-header h2 { margin: 0; font-size: 15px; }
.settings-header p { display: none; }
.settings-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.settings-status-tabs { display: flex; gap: 4px; padding: 3px; border-radius: 9px; background: var(--soft); }
.settings-status-tabs button { border: 0; border-radius: 7px; padding: 7px 9px; background: transparent; color: var(--muted); font-size: 8px; cursor: pointer; }
.settings-status-tabs button.active { background: white; color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.settings-status-tabs span { color: #999ba1; }
.settings-search { max-width: 300px; }
.settings-list { padding: 0 17px; }
.setting-row { min-height: 66px; display: grid; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: 14px; border-bottom: 1px solid #efeee9; }
.setting-row:last-child { border-bottom: 0; }
.setting-identity { min-width: 0; display: flex; align-items: center; gap: 11px; }
.setting-order { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 7px; background: var(--soft); color: #8c8e94; font-size: 8px; }
.setting-identity strong, .setting-identity small { display: block; }
.setting-identity strong { font-size: 10px; }
.setting-identity small { margin-top: 5px; color: var(--muted); font-size: 8px; }
.managed-label { color: var(--muted); font-size: 8px; }
.switch-control { width: 33px; height: 19px; border: 0; border-radius: 99px; padding: 2px; background: #d9d8d4; cursor: pointer; }
.switch-control span { display: block; width: 15px; height: 15px; border-radius: 50%; background: white; transition: transform .15s; box-shadow: 0 1px 4px rgba(0,0,0,.18); }
.switch-control.on { background: var(--violet); }
.switch-control.on span { transform: translateX(14px); }
.settings-empty { display: grid; place-items: center; min-height: 360px; padding: 35px; text-align: center; }
.settings-empty > span { display: none; }
.settings-empty h3 { margin: 0; font-size: 13px; }
.settings-empty p { max-width: 430px; margin: 9px 0 18px; color: var(--muted); font-size: 9px; line-height: 1.6; }

dialog { width: min(720px, calc(100vw - 34px)); max-height: calc(100vh - 34px); border: 0; border-radius: 16px; padding: 0; background: white; box-shadow: 0 28px 90px rgba(25,26,31,.22); }
dialog::backdrop { background: rgba(20,21,25,.48); backdrop-filter: blur(3px); }
.dialog-card { display: grid; gap: 17px; padding: 25px; }
.dialog-card h2 { margin: 0; font-size: 21px; letter-spacing: -.04em; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.dialog-close { border: 0; border-radius: 8px; padding: 8px 10px; background: var(--soft); font-size: 8px; font-weight: 700; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid label.full { grid-column: 1 / -1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 100; max-width: min(380px, calc(100vw - 48px)); border-radius: 10px; padding: 12px 15px; background: #202126; color: white; box-shadow: 0 12px 35px rgba(0,0,0,.2); font-size: 10px; }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
  .settings-shell { grid-template-columns: 200px 1fr; }
}

@media (max-width: 760px) {
  :root { --sidebar: 240px; }
  .login-layout { grid-template-columns: 1fr; background: var(--paper); }
  .login-brand { display: none; }
  .login-panel { min-height: 100vh; }
  .login-card-brand { display: block; }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 35; display: block; border: 0; background: rgba(20,21,25,.45); }
  .workspace { margin-left: 0; }
  .topbar { height: 68px; padding: 0 17px; }
  .topbar h1 { font-size: 17px; }
  .mobile-menu { display: block; }
  .top-refresh { display: none; }
  #content { padding: 22px 17px 38px; }
  .settings-shell { grid-template-columns: 1fr; }
  .settings-menu { display: flex; gap: 7px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .settings-menu-group { display: contents; }
  .settings-menu-group h3 { display: none; }
  .settings-menu-item { min-width: max-content; width: auto; grid-template-columns: auto auto; border: 1px solid var(--line); background: white; }
  .settings-toolbar { align-items: stretch; flex-direction: column; }
  .settings-search { max-width: none; width: 100%; }
  .notice-card { grid-template-columns: 1fr; }
  .notice-meta { text-align: left; }
}

@media (max-width: 520px) {
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 116px; }
  .primary-button.compact { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid label.full { grid-column: auto; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .setting-row { grid-template-columns: 1fr auto; }
  .setting-row > .status { display: none; }
}
