@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&family=Roboto:wght@400;500;700&display=swap');

:root {
  --color-primary:        #693687;
  --color-primary-hover:  #552b6e;
  --color-primary-light:  #9a63c4;
  --color-primary-soft:   #f2ebf7;
  --color-primary-pale:   #dcc9ea;
  --color-ink:            #221a29;
  --color-body:           #5c5566;
  --color-muted:          #8f8899;
  --color-border:         #e9e4ee;
  --color-surface:        #ffffff;
  --color-surface-alt:    #f8f6fa;
  --color-dark-bg:        #1b1122;
  --color-dark-text:      #b3a8bf;
  --color-success:        #1e9e5a;
  --color-success-soft:   #e6f6ee;
  --color-warning:        #f5a623;
  --color-warning-soft:   #fef4e3;
  --color-warning-text:   #b97a12;
  --color-error:          #d93025;
  --color-error-soft:     #fdeceb;
  --font-display: "Poppins", "Segoe UI", system-ui, sans-serif;
  --font-body:    "Roboto", "Helvetica Neue", system-ui, sans-serif;
  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.375rem;
  --text-2xl:  1.75rem;
  --text-3xl:  2.25rem;
  --text-4xl:  3rem;
  --weight-regular:  400;
  --weight-medium:   500;
  --weight-semibold: 600;
  --weight-bold:     700;
  --leading-tight:  1.2;
  --leading-normal: 1.6;
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --container-max:  1140px;
  --container-pad:  1rem;
  --grid-gap:       1.5rem;
  --sidebar-w:      240px;
  --radius-sm:   6px;
  --radius-md:   12px;
  --radius-lg:   20px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 3px rgba(34, 26, 41, 0.06);
  --shadow-md: 0 6px 18px rgba(34, 26, 41, 0.09);
  --shadow-lg: 0 14px 34px rgba(34, 26, 41, 0.15);
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 150ms;
  --duration-base: 250ms;
  --duration-slow: 500ms;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--color-body);
  background: var(--color-surface-alt);
  line-height: 1.6;
}
h1,h2,h3,h4,h5,h6 { font-family: var(--font-display); color: var(--color-ink); line-height: var(--leading-tight); }

/* ============ APP SHELL ============ */
.app { width: 1440px; margin: 0 auto; display: flex; min-height: 100vh; background: var(--color-surface-alt); }

/* ============ LOGIN SCREEN ============ */
.login-screen { width: 1440px; margin: 0 auto; min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--color-dark-bg) 0%, #2d1b3d 50%, var(--color-primary) 100%); }
.login-container { background: var(--color-surface); border-radius: var(--radius-lg); padding: 48px; max-width: 820px; width: 100%; box-shadow: var(--shadow-lg); }
.login-header { text-align: center; margin-bottom: 36px; }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 16px; }
.login-brand-logo { width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, var(--color-primary-light), var(--color-primary)); display: flex; align-items: center; justify-content: center; color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 20px; }
.login-brand-name { font-size: 24px; font-weight: 700; color: var(--color-ink); font-family: var(--font-display); }
.login-subtitle { color: var(--color-muted); font-size: 14px; }
.user-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 28px; }
.user-card { border: 2px solid var(--color-border); border-radius: var(--radius-md); padding: 16px; cursor: pointer; transition: all var(--duration-base) var(--ease-standard); text-align: center; }
.user-card:hover { border-color: var(--color-primary-pale); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.user-card.selected { border-color: var(--color-primary); background: var(--color-primary-soft); }
.user-card .avatar { width: 48px; height: 48px; border-radius: 50%; background: linear-gradient(135deg, #c084d8, var(--color-primary)); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; font-size: 16px; margin: 0 auto 12px; font-family: var(--font-display); }
.user-card .card-name { font-weight: 600; color: var(--color-ink); font-size: 13.5px; margin-bottom: 4px; }
.user-card .card-role { font-size: 11.5px; color: var(--color-muted); margin-bottom: 6px; }
.user-card .card-scope { font-size: 10.5px; color: var(--color-primary); background: var(--color-primary-soft); padding: 2px 8px; border-radius: var(--radius-pill); display: inline-block; }
.user-card .card-geo { font-size: 10px; color: var(--color-warning-text); background: var(--color-warning-soft); padding: 2px 6px; border-radius: var(--radius-pill); margin-left: 4px; }
.login-form { display: flex; flex-direction: column; gap: 12px; max-width: 360px; margin: 0 auto; }
.login-form input { padding: 10px 16px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); font-size: 13.5px; font-family: var(--font-body); outline: none; transition: border-color var(--duration-fast); }
.login-form input:focus { border-color: var(--color-primary); }

/* ============ SIDEBAR ============ */
.sidebar { width: var(--sidebar-w); background: var(--color-dark-bg); color: var(--color-dark-text); position: sticky; top: 0; align-self: flex-start; height: 100vh; display: flex; flex-direction: column; overflow-y: auto; flex-shrink: 0; }
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
.brand { padding: 20px 20px 20px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(255,255,255,0.06); margin-bottom: 12px; }
.brand-logo { width: 34px; height: 34px; border-radius: 8px; background: linear-gradient(135deg, var(--color-primary-light), var(--color-primary)); display: flex; align-items: center; justify-content: center; color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 16px; flex-shrink: 0; }
.brand-name { font-family: var(--font-display); font-weight: 600; color: #fff; font-size: 16px; letter-spacing: 0.2px; }
.brand-sub { font-size: 11px; color: var(--color-dark-text); }

.nav-section { margin-bottom: 4px; }
.nav-section-title { padding: 10px 20px 6px; font-size: 10px; text-transform: uppercase; letter-spacing: 1.2px; color: rgba(179,168,191,0.55); font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: space-between; user-select: none; }
.nav-section-title:hover { color: rgba(179,168,191,0.8); }
.nav-section-title .chevron { transition: transform var(--duration-fast); font-size: 10px; }
.nav-section.collapsed .nav-section-title .chevron { transform: rotate(-90deg); }
.nav-section.collapsed .nav-items { display: none; }
.nav-items { list-style: none; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 20px; margin: 1px 8px; border-radius: 8px; font-size: 13px; color: var(--color-dark-text); cursor: pointer; transition: background var(--duration-fast), color var(--duration-fast); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover { background: rgba(255,255,255,0.04); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, rgba(105,54,135,0.35), rgba(105,54,135,0.15)); color: #fff; font-weight: 500; box-shadow: inset 3px 0 0 var(--color-primary-light); }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.9; }
.nav-badge { margin-left: auto; background: var(--color-primary); color: #fff; font-size: 10px; padding: 2px 7px; border-radius: var(--radius-pill); font-weight: 600; }

.sidebar-footer { margin-top: auto; padding: 14px 16px; border-top: 1px solid rgba(255,255,255,0.06); display: flex; align-items: center; gap: 10px; }
.avatar-sm { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg,#c084d8,var(--color-primary)); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; font-size: 12px; font-family: var(--font-display); flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; line-height: 1.3; }
.user-name { color: #fff; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--color-dark-text); }
.logout-btn { background: none; border: none; color: var(--color-dark-text); cursor: pointer; padding: 6px; border-radius: 6px; transition: background var(--duration-fast); flex-shrink: 0; }
.logout-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }

/* ============ MAIN AREA ============ */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ============ TOPBAR ============ */
.topbar { background: var(--color-surface); padding: 12px 28px; display: flex; align-items: center; gap: 16px; border-bottom: 1px solid var(--color-border); position: sticky; top: 0; z-index: 10; }
.crumbs { font-size: 12.5px; color: var(--color-muted); }
.crumbs a { color: var(--color-muted); text-decoration: none; }
.crumbs a:hover { color: var(--color-primary); }
.crumbs strong { color: var(--color-ink); font-weight: 500; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--color-border); background: var(--color-surface); display: flex; align-items: center; justify-content: center; cursor: pointer; position: relative; color: var(--color-body); transition: background var(--duration-fast); }
.icon-btn:hover { background: var(--color-surface-alt); }
.icon-btn .dot { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; background: var(--color-error); border-radius: 50%; border: 2px solid #fff; }
.user-dropdown { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm); transition: background var(--duration-fast); position: relative; }
.user-dropdown:hover { background: var(--color-surface-alt); }
.user-dropdown .dropdown-menu { display: none; position: absolute; top: 100%; right: 0; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: 8px 0; min-width: 180px; z-index: 100; }
.user-dropdown.open .dropdown-menu { display: block; }
.dropdown-item { padding: 8px 16px; font-size: 13px; color: var(--color-body); cursor: pointer; display: flex; align-items: center; gap: 8px; }
.dropdown-item:hover { background: var(--color-surface-alt); }
.dropdown-item.danger { color: var(--color-error); }

/* ============ PAGE LAYOUT ============ */
.page { padding: 24px 28px 40px; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }
.page-title { font-size: 24px; font-weight: 600; color: var(--color-ink); }
.page-sub { font-size: 13px; color: var(--color-muted); margin-top: 4px; }
.header-actions { display: flex; gap: 10px; }

/* ============ BUTTONS ============ */
.btn { font-family: var(--font-display); font-weight: 500; font-size: 13px; padding: 9px 18px; border-radius: var(--radius-pill); border: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: all var(--duration-base) var(--ease-standard); white-space: nowrap; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-ghost { background: var(--color-surface); color: var(--color-ink); border: 1px solid var(--color-border); }
.btn-ghost:hover { background: var(--color-surface-alt); }
.btn-success { background: var(--color-success); color: #fff; }
.btn-success:hover { background: #178a4e; }
.btn-danger { background: var(--color-error); color: #fff; }
.btn-danger:hover { background: #c22a20; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============ FILTER BAR ============ */
.filter-bar { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 12px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.filter-group { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.filter-label { color: var(--color-muted); font-weight: 500; }
.filter-select { background: var(--color-surface-alt); border: 1px solid var(--color-border); padding: 6px 28px 6px 10px; border-radius: var(--radius-sm); font-size: 12.5px; color: var(--color-ink); font-family: var(--font-body); appearance: none; cursor: pointer; background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235c5566' stroke-width='2.5'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right 8px center; }
.filter-divider { width: 1px; height: 22px; background: var(--color-border); }
.filter-toggle { display: flex; background: var(--color-surface-alt); border: 1px solid var(--color-border); border-radius: var(--radius-pill); overflow: hidden; }
.filter-toggle-btn { padding: 5px 12px; font-size: 12px; border: none; background: transparent; cursor: pointer; color: var(--color-muted); font-family: var(--font-body); transition: all var(--duration-fast); }
.filter-toggle-btn.active { background: var(--color-primary); color: #fff; }

/* ============ KPI CARDS ============ */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi-card { background: var(--color-surface); border-radius: var(--radius-md); padding: 18px; border: 1px solid var(--color-border); box-shadow: var(--shadow-sm); position: relative; overflow: hidden; cursor: pointer; transition: box-shadow var(--duration-base) var(--ease-standard), transform var(--duration-base) var(--ease-standard); }
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.kpi-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.kpi-label { font-size: 11.5px; color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.8px; font-weight: 600; }
.kpi-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--color-primary-soft); color: var(--color-primary); display: flex; align-items: center; justify-content: center; }
.kpi-icon svg { width: 18px; height: 18px; }
.kpi-value { font-family: var(--font-display); font-size: 28px; font-weight: 600; color: var(--color-ink); line-height: 1.1; }
.kpi-unit { font-size: 15px; color: var(--color-muted); font-weight: 500; margin-left: 2px; }
.kpi-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.trend { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: var(--radius-pill); }
.trend.up { color: var(--color-success); background: var(--color-success-soft); }
.trend.down { color: var(--color-error); background: var(--color-error-soft); }
.trend.warn { color: var(--color-warning-text); background: var(--color-warning-soft); }
.kpi-caption { font-size: 11px; color: var(--color-muted); }

/* ============ PANELS / CARDS ============ */
.panel { background: var(--color-surface); border-radius: var(--radius-md); border: 1px solid var(--color-border); box-shadow: var(--shadow-sm); overflow: hidden; }
.panel-header { padding: 16px 18px; border-bottom: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; }
.panel-title { font-size: 15px; font-weight: 600; color: var(--color-ink); }
.panel-sub { font-size: 12px; color: var(--color-muted); margin-top: 2px; }
.panel-body { padding: 18px; }

.section-grid { display: grid; gap: 16px; margin-bottom: 20px; }
.section-grid-2 { grid-template-columns: 2fr 1fr; }
.section-grid-equal { grid-template-columns: 1fr 1fr; }

/* ============ TABLES ============ */
table.data { width: 100%; border-collapse: collapse; }
table.data thead th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.7px; font-weight: 600; color: var(--color-muted); padding: 10px 16px; background: var(--color-surface-alt); border-bottom: 1px solid var(--color-border); cursor: default; white-space: nowrap; }
table.data thead th.sortable { cursor: pointer; user-select: none; }
table.data thead th.sortable:hover { color: var(--color-primary); }
table.data thead th .sort-icon { margin-left: 4px; font-size: 10px; }
table.data tbody td { padding: 12px 16px; font-size: 13px; color: var(--color-body); border-bottom: 1px solid var(--color-border); vertical-align: middle; }
table.data tbody tr { transition: background var(--duration-fast); }
table.data tbody tr:hover { background: var(--color-surface-alt); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr.clickable { cursor: pointer; }

.table-footer { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--color-border); font-size: 12.5px; color: var(--color-muted); }
.pager { display: flex; gap: 4px; }
.pager button { width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-body); font-size: 12px; cursor: pointer; transition: all var(--duration-fast); font-family: var(--font-body); }
.pager button:hover { background: var(--color-surface-alt); }
.pager button.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* ============ STATUS CHIPS ============ */
.status-chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--radius-pill); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.status-chip .dot { width: 6px; height: 6px; border-radius: 50%; }
.status-ok { background: var(--color-success-soft); color: var(--color-success); }
.status-ok .dot { background: var(--color-success); }
.status-warn { background: var(--color-warning-soft); color: var(--color-warning-text); }
.status-warn .dot { background: var(--color-warning); }
.status-err { background: var(--color-error-soft); color: var(--color-error); }
.status-err .dot { background: var(--color-error); }
.status-info { background: var(--color-primary-soft); color: var(--color-primary); }
.status-info .dot { background: var(--color-primary); }
.status-neutral { background: var(--color-surface-alt); color: var(--color-muted); }
.status-neutral .dot { background: var(--color-muted); }

/* ============ PROGRESS BAR ============ */
.progress-cell { display: flex; align-items: center; gap: 10px; min-width: 120px; }
.progress-bar { flex: 1; height: 6px; background: var(--color-primary-pale); border-radius: var(--radius-pill); overflow: hidden; }
.progress-fill { height: 100%; border-radius: var(--radius-pill); background: var(--color-primary); transition: width var(--duration-base); }
.progress-fill.ok { background: var(--color-success); }
.progress-fill.warn { background: var(--color-warning); }
.progress-fill.err { background: var(--color-error); }
.progress-val { font-family: var(--font-display); font-weight: 600; font-size: 13px; color: var(--color-ink); min-width: 40px; text-align: right; }

/* ============ TABS ============ */
.tabs { display: flex; gap: 4px; background: var(--color-surface-alt); padding: 3px; border-radius: var(--radius-pill); }
.tab { padding: 6px 16px; font-size: 12.5px; font-weight: 500; color: var(--color-muted); border-radius: var(--radius-pill); cursor: pointer; transition: all var(--duration-fast); font-family: var(--font-display); }
.tab:hover { color: var(--color-ink); }
.tab.active { background: var(--color-surface); color: var(--color-primary); box-shadow: var(--shadow-sm); }
.tabs-underline { display: flex; gap: 0; border-bottom: 2px solid var(--color-border); margin-bottom: 16px; }
.tab-underline { padding: 10px 20px; font-size: 13.5px; font-weight: 500; color: var(--color-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all var(--duration-fast); font-family: var(--font-display); }
.tab-underline:hover { color: var(--color-ink); }
.tab-underline.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

/* ============ MODAL ============ */
.modal-overlay { position: fixed; inset: 0; background: rgba(27,17,34,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; animation: fadeIn var(--duration-base) var(--ease-standard); }
.modal { background: var(--color-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 520px; max-height: 85vh; overflow-y: auto; animation: scaleIn var(--duration-base) var(--ease-standard); }
.modal-header { padding: 20px 24px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--color-border); }
.modal-title { font-size: 18px; font-weight: 600; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--color-muted); padding: 4px; border-radius: 6px; }
.modal-close:hover { background: var(--color-surface-alt); color: var(--color-ink); }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--color-border); display: flex; justify-content: flex-end; gap: 10px; }

/* ============ TOAST ============ */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--color-dark-bg); color: #fff; padding: 12px 20px; border-radius: var(--radius-md); font-size: 13px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px; animation: slideInRight var(--duration-base) var(--ease-standard); max-width: 380px; }
.toast.success { border-left: 4px solid var(--color-success); }
.toast.error { border-left: 4px solid var(--color-error); }
.toast.info { border-left: 4px solid var(--color-primary); }

/* ============ FORMS ============ */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12.5px; font-weight: 500; color: var(--color-ink); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea { width: 100%; padding: 8px 12px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); font-size: 13px; font-family: var(--font-body); color: var(--color-ink); background: var(--color-surface); transition: border-color var(--duration-fast); }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--color-primary); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-select { appearance: none; background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235c5566' stroke-width='2.5'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; cursor: pointer; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-hint { font-size: 11.5px; color: var(--color-muted); margin-top: 4px; }
.form-error { font-size: 11.5px; color: var(--color-error); margin-top: 4px; }

/* ============ ACTION LINK ============ */
.action-link { color: var(--color-primary); font-weight: 500; font-size: 12.5px; cursor: pointer; text-decoration: none; }
.action-link:hover { color: var(--color-primary-hover); text-decoration: underline; }

/* ============ DETAIL PANEL ============ */
.detail-panel { background: var(--color-surface-alt); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 18px; margin-top: 12px; animation: fadeIn var(--duration-base) var(--ease-standard); }
.detail-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--color-border); font-size: 13px; }
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--color-muted); font-weight: 500; }
.detail-value { color: var(--color-ink); font-weight: 500; text-align: right; }

/* ============ APPROVAL BAR ============ */
.approval-bar { background: var(--color-surface-alt); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 16px; margin-top: 12px; }
.approval-bar .approval-actions { display: flex; gap: 10px; margin-top: 12px; }

/* ============ DONUT CHART ============ */
.donut-wrap { display: flex; align-items: center; gap: 24px; }
.donut { position: relative; width: 140px; height: 140px; flex-shrink: 0; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.donut-val { font-family: var(--font-display); font-size: 22px; font-weight: 600; color: var(--color-ink); line-height: 1; }
.donut-label-text { font-size: 11px; color: var(--color-muted); margin-top: 4px; }
.legend { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend-name { flex: 1; color: var(--color-body); }
.legend-val { font-weight: 600; color: var(--color-ink); font-family: var(--font-display); }

/* ============ COMMUNITY CELL ============ */
.community-cell { display: flex; align-items: center; gap: 10px; }
.community-thumb { width: 36px; height: 36px; border-radius: 8px; background: linear-gradient(135deg, var(--color-primary-light), var(--color-primary)); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; font-size: 12px; font-family: var(--font-display); flex-shrink: 0; }
.community-name { font-weight: 500; color: var(--color-ink); font-size: 13px; }
.community-loc { font-size: 11px; color: var(--color-muted); }

/* ============ SEARCH ============ */
.search-bar { display: flex; align-items: center; gap: 8px; background: var(--color-surface-alt); border: 1px solid var(--color-border); border-radius: var(--radius-pill); padding: 7px 14px; }
.search-bar input { border: none; background: transparent; outline: none; font-size: 13px; font-family: var(--font-body); color: var(--color-body); flex: 1; }
.search-bar svg { flex-shrink: 0; color: var(--color-muted); }

/* ============ BADGE ============ */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 600; }
.badge-primary { background: var(--color-primary-soft); color: var(--color-primary); }
.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning-text); }
.badge-danger { background: var(--color-error-soft); color: var(--color-error); }

/* ============ EMPTY STATE ============ */
.empty-state { text-align: center; padding: 48px 20px; color: var(--color-muted); }
.empty-state svg { margin-bottom: 12px; opacity: 0.4; }
.empty-state h3 { font-size: 16px; margin-bottom: 6px; color: var(--color-ink); }
.empty-state p { font-size: 13px; }

/* ============ TREE VIEW ============ */
.tree-item { padding: 8px 12px; display: flex; align-items: center; gap: 8px; cursor: pointer; border-radius: var(--radius-sm); transition: background var(--duration-fast); font-size: 13px; }
.tree-item:hover { background: var(--color-surface-alt); }
.tree-item.level-1 { padding-left: 36px; }
.tree-toggle { width: 20px; color: var(--color-muted); }

/* ============ CALENDAR GRID ============ */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--color-border); border: 1px solid var(--color-border); border-radius: var(--radius-md); overflow: hidden; }
.calendar-header { background: var(--color-surface-alt); padding: 8px; text-align: center; font-size: 11px; font-weight: 600; color: var(--color-muted); text-transform: uppercase; }
.calendar-day { background: var(--color-surface); padding: 6px 8px; min-height: 80px; font-size: 12px; }
.calendar-day .day-num { font-weight: 600; color: var(--color-ink); margin-bottom: 4px; }
.calendar-day.other-month { background: var(--color-surface-alt); }
.calendar-day.other-month .day-num { color: var(--color-muted); }
.calendar-event { background: var(--color-primary-soft); color: var(--color-primary); padding: 2px 6px; border-radius: 4px; font-size: 10px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.calendar-event.overdue { background: var(--color-error-soft); color: var(--color-error); }
.calendar-event.completed { background: var(--color-success-soft); color: var(--color-success); }

/* ============ INLINE EDIT ============ */
.inline-edit { border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 4px 8px; font-size: 13px; font-family: var(--font-body); width: 100px; }
.inline-edit:focus { outline: none; border-color: var(--color-primary); }

/* ============ KEY-VALUE EDITOR ============ */
.kv-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.kv-row input { flex: 1; }
.kv-remove { background: none; border: none; color: var(--color-error); cursor: pointer; font-size: 16px; padding: 4px; }

/* ============ TOOLTIP ============ */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after { content: attr(data-tooltip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--color-dark-bg); color: #fff; padding: 4px 10px; border-radius: var(--radius-sm); font-size: 11px; white-space: nowrap; z-index: 100; pointer-events: none; }

/* ============ ANIMATIONS ============ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideDown { from { max-height: 0; opacity: 0; } to { max-height: 500px; opacity: 1; } }
.animate-in { animation: fadeIn var(--duration-base) var(--ease-standard); }

/* ============ LINE ITEMS ============ */
.line-items-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.line-items-table th { text-align: left; font-size: 11px; font-weight: 600; color: var(--color-muted); padding: 6px 8px; border-bottom: 1px solid var(--color-border); }
.line-items-table td { padding: 6px 8px; font-size: 13px; border-bottom: 1px solid var(--color-border); }
.line-items-table input { width: 100%; padding: 4px 8px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); font-size: 12px; }

/* ============ UPLOAD AREA ============ */
.upload-area { border: 2px dashed var(--color-border); border-radius: var(--radius-md); padding: 24px; text-align: center; color: var(--color-muted); cursor: pointer; transition: border-color var(--duration-fast); }
.upload-area:hover { border-color: var(--color-primary-pale); }

/* ============ MINI SPARKLINE ============ */
.mini-spark { width: 100%; height: 32px; margin-top: 8px; }

/* ============ UTILITIES ============ */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-primary { color: var(--color-primary); }
.text-success { color: var(--color-success); }
.text-error { color: var(--color-error); }
.text-warning { color: var(--color-warning-text); }
.text-muted { color: var(--color-muted); }
.font-display { font-family: var(--font-display); }
.font-semibold { font-weight: 600; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.red-text { color: var(--color-error); font-weight: 600; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.chart-wrap { position: relative; }
.foot { padding: 16px 28px; border-top: 1px solid var(--color-border); font-size: 11.5px; color: var(--color-muted); display: flex; justify-content: space-between; }
