:root {
  --navy: #0f2a43;
  --navy-2: #173c5e;
  --ink: #1d2939;
  --muted: #6c7a89;
  --soft: #f5f7fa;
  --line: #e6eaf0;
  --white: #ffffff;
  --teal: #1b9b8c;
  --teal-soft: #e5f6f3;
  --amber: #e29a2d;
  --amber-soft: #fff3dc;
  --red: #c95757;
  --red-soft: #fde9e9;
  --blue: #4379d6;
  --blue-soft: #eaf0ff;
  --shadow: 0 14px 36px rgba(15, 42, 67, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--soft);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--soft); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { display: flex; min-height: 100vh; }

.sidebar { width: 260px; flex: 0 0 260px; padding: 28px 16px 18px; display: flex; flex-direction: column; background: var(--navy); color: #dce8f3; }
.brand { display: flex; gap: 12px; align-items: center; padding: 0 12px 34px; }
.brand-logo { width: 52px; height: 52px; object-fit: contain; border-radius: 10px; background: #fff; padding: 3px; }
.brand-name { color: var(--white); font-weight: 760; letter-spacing: -.02em; }
.brand-subtitle { margin-top: 3px; color: #93acc2; font-size: 11px; }
.main-nav { display: grid; gap: 6px; }
.nav-item { width: 100%; border: 0; border-radius: 10px; display: flex; align-items: center; gap: 12px; padding: 12px; color: #a8bdd0; background: transparent; text-align: left; transition: .18s ease; }
.nav-item:hover { color: var(--white); background: rgba(255,255,255,.08); }
.nav-item.active { color: var(--white); background: #1b476d; box-shadow: inset 3px 0 #f6c967; }
.nav-item.secondary { margin-top: 8px; }
.nav-icon { width: 20px; text-align: center; font-size: 18px; opacity: .9; }
.nav-count { margin-left: auto; padding: 2px 7px; border-radius: 20px; color: #afc3d4; background: rgba(255,255,255,.09); font-size: 11px; }
.sidebar-bottom { margin-top: auto; }
.sync-card { margin: 18px 5px; padding: 14px; border: 1px solid rgba(255,255,255,.1); border-radius: 12px; background: rgba(0,0,0,.12); }
.sync-title { display: flex; align-items: center; gap: 7px; color: #eff7ff; font-size: 12px; font-weight: 650; }
.sync-caption { margin-top: 7px; color: #8fa8bc; font-size: 11px; line-height: 1.45; }
.status-dot { width: 8px; height: 8px; display: inline-block; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 3px rgba(226,154,45,.16); }
.status-dot.online { background: #68d2a2; box-shadow: 0 0 0 3px rgba(104,210,162,.15); }
.status-dot.offline { background: #e27676; box-shadow: 0 0 0 3px rgba(226,118,118,.14); }
.account-chip { display: flex; align-items: center; gap: 9px; padding: 14px 8px 4px; border-top: 1px solid rgba(255,255,255,.1); font-size: 11px; }
.account-chip strong { display: block; color: #edf5fb; font-size: 12px; }
.account-chip small { display: block; margin-top: 3px; color: #8fa8bc; }
.avatar { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; color: var(--navy); background: #ccebe6; font-weight: 800; }

.main-area { min-width: 0; flex: 1; }
.topbar { min-height: 90px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 20px 38px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.92); }
.page-heading h1 { margin: 3px 0 0; color: var(--navy); font-size: 25px; letter-spacing: -.035em; }
.eyebrow { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.search-box { width: min(290px, 28vw); display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; color: #9aa7b5; background: var(--soft); }
.search-box input { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 13px; }
.icon-button, .close-button { border: 0; color: var(--muted); background: transparent; }
.icon-button { width: 37px; height: 37px; border: 1px solid var(--line); border-radius: 10px; font-size: 19px; }
.icon-button:hover { color: var(--navy); background: var(--soft); }
.primary-button, .ghost-button, .danger-button { border: 0; border-radius: 9px; padding: 10px 15px; font-weight: 700; font-size: 13px; transition: .16s ease; }
.primary-button { color: var(--white); background: var(--navy); box-shadow: 0 6px 14px rgba(15,42,67,.16); }
.primary-button:hover { background: var(--navy-2); transform: translateY(-1px); }
.ghost-button { color: var(--navy); border: 1px solid var(--line); background: var(--white); }
.ghost-button:hover { background: var(--soft); }
.danger-button { color: var(--red); background: var(--red-soft); }
.mobile-menu { display: none; border: 0; color: var(--navy); background: transparent; font-size: 22px; }

.content { max-width: 1440px; margin: 0 auto; padding: 34px 38px 50px; }
.welcome { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.welcome h2 { margin: 0; color: var(--navy); font-size: 28px; letter-spacing: -.04em; }
.welcome p { margin: 7px 0 0; color: var(--muted); font-size: 14px; }
.date-label { color: var(--muted); font-size: 12px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 24px; }
.stat-card { padding: 19px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); box-shadow: 0 5px 18px rgba(15,42,67,.035); }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 650; }
.stat-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: var(--navy); background: var(--blue-soft); font-size: 17px; }
.stat-icon.teal { color: #08756a; background: var(--teal-soft); }
.stat-icon.amber { color: #9a5c00; background: var(--amber-soft); }
.stat-icon.red { color: #a13b3b; background: var(--red-soft); }
.stat-value { margin-top: 16px; color: var(--navy); font-size: 29px; font-weight: 760; letter-spacing: -.05em; }
.stat-note { margin-top: 4px; color: var(--muted); font-size: 11px; }
.panel-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, .9fr); gap: 18px; }
.panel { border: 1px solid var(--line); border-radius: 16px; background: var(--white); box-shadow: 0 9px 26px rgba(15,42,67,.055); overflow: hidden; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.panel-header h3 { margin: 0; color: var(--navy); font-size: 15px; letter-spacing: -.02em; }
.panel-link { border: 0; color: var(--blue); background: transparent; font-size: 12px; font-weight: 700; }
.panel-body { padding: 5px 20px 15px; }
.panel-kicker { display: block; margin-bottom: 4px; color: #c19335; font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.recent-panel { position: relative; border-color: #303b47; background: linear-gradient(145deg, #162534 0%, #263847 60%, #32495a 100%); box-shadow: 0 12px 30px rgba(15,42,67,.16); }
.recent-panel::before { position: absolute; top: 0; left: 0; right: 0; height: 4px; content: ""; background: linear-gradient(90deg, #b33f48 0%, #df6f52 48%, #e6c062 100%); }
.recent-panel .panel-header { padding-top: 22px; border-color: rgba(255,255,255,.14); }
.recent-panel .panel-header h3 { color: #fff; }
.recent-panel .panel-link { color: #f2cf79; }
.recent-panel .panel-link:hover { color: #fff; }
.recent-panel .list-card { border: 1px solid rgba(255,255,255,.12); border-radius: 12px; background: rgba(255,255,255,.96); box-shadow: 0 4px 12px rgba(0,0,0,.12); transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.recent-panel .list-card:hover { transform: translateY(-2px); border-color: #d9b457; box-shadow: 0 10px 22px rgba(0,0,0,.24); }
.recent-panel .card-title { padding-right: 3px; }
.recent-panel .panel-body { padding-top: 11px; }
.empty-state { padding: 42px 20px; color: var(--muted); text-align: center; }
.empty-state .empty-icon { width: 45px; height: 45px; display: grid; place-items: center; margin: 0 auto 12px; border-radius: 13px; color: var(--navy); background: var(--soft); font-size: 21px; }
.empty-state strong { display: block; color: var(--navy); font-size: 14px; }
.empty-state p { max-width: 330px; margin: 7px auto 0; font-size: 12px; line-height: 1.5; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 10px; color: #8a98a7; font-size: 10px; font-weight: 760; letter-spacing: .08em; text-align: left; text-transform: uppercase; }
td { padding: 14px 10px; border-top: 1px solid var(--line); color: #445364; font-size: 12px; vertical-align: middle; }
tr:first-child td { border-top: 0; }
.cell-main { color: var(--navy); font-weight: 700; }
.cell-sub { margin-top: 3px; color: var(--muted); font-size: 11px; }
.anaf-list-status.success { color: #08756a; }
.anaf-list-status.error { color: #a13b3b; }
.status-chip { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 20px; font-size: 10px; font-weight: 760; white-space: nowrap; }
.status-chip.active, .status-chip.done { color: #08756a; background: var(--teal-soft); }
.status-chip.planned, .status-chip.draft { color: #8b5b0a; background: var(--amber-soft); }
.status-chip.in_progress { color: #2d5da9; background: var(--blue-soft); }
.status-chip.expired, .status-chip.paused, .status-chip.overdue { color: #a13b3b; background: var(--red-soft); }
.status-chip::before { width: 5px; height: 5px; content: ""; display: inline-block; border-radius: 50%; background: currentColor; }
.overdue-text { color: var(--red) !important; }

.section-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.section-toolbar h2 { margin: 0; color: var(--navy); font-size: 21px; letter-spacing: -.03em; }
.toolbar-note { margin-top: 4px; color: var(--muted); font-size: 12px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
.filter-button { border: 1px solid var(--line); border-radius: 20px; padding: 7px 12px; color: var(--muted); background: var(--white); font-size: 11px; font-weight: 650; }
.filter-button.active, .filter-button:hover { border-color: #bcd0e0; color: var(--navy); background: #eef4f8; }
.list-card { padding: 17px 19px; border: 1px solid var(--line); border-radius: 13px; background: var(--white); }
.list-card + .list-card { margin-top: 10px; }
.card-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.card-title { color: var(--navy); font-size: 14px; font-weight: 750; }
.card-meta { display: flex; flex-wrap: wrap; gap: 11px; margin-top: 8px; color: var(--muted); font-size: 11px; }
.card-meta span { display: inline-flex; align-items: center; gap: 5px; }
.card-actions { display: flex; gap: 6px; }
.small-button { border: 1px solid var(--line); border-radius: 7px; padding: 6px 9px; color: var(--muted); background: var(--white); font-size: 11px; }
.small-button:hover { color: var(--navy); background: var(--soft); }
.small-button.danger:hover { color: var(--red); background: var(--red-soft); }
.small-button.pdf-button { color: var(--teal); border-color: rgba(15,118,110,.24); }
.small-button.pdf-button:hover { color: var(--navy); background: var(--teal-soft); }
.template-help { color: var(--muted); font-size: 12px; line-height: 1.45; padding: 2px 0; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 15px; }
.settings-card { max-width: 760px; padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: var(--white); }
.settings-card h3 { margin: 0 0 8px; color: var(--navy); font-size: 16px; }
.settings-card p { margin: 0 0 18px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.info-box { margin-top: 18px; padding: 13px 14px; border-radius: 10px; color: #35556e; background: #eef6fb; font-size: 12px; line-height: 1.5; }

.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(12, 31, 49, .46); backdrop-filter: blur(4px); }
.modal-backdrop.hidden, .hidden { display: none !important; }
.modal { width: min(640px, 100%); max-height: calc(100vh - 40px); overflow: auto; border-radius: 16px; background: var(--white); box-shadow: var(--shadow); }
.modal-header { display: flex; justify-content: space-between; gap: 12px; padding: 22px 24px 18px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 4px 0 0; color: var(--navy); font-size: 21px; letter-spacing: -.03em; }
.close-button { width: 30px; height: 30px; border-radius: 7px; font-size: 25px; line-height: 1; }
.close-button:hover { background: var(--soft); }
#record-form { padding: 20px 24px 22px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-field { display: grid; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { color: #536374; font-size: 11px; font-weight: 700; }
.form-field input, .form-field select, .form-field textarea { width: 100%; border: 1px solid #dce3ea; border-radius: 8px; padding: 10px 11px; outline: 0; color: var(--ink); background: #fbfcfd; font-size: 13px; }
.form-field textarea { min-height: 82px; resize: vertical; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: #7ea7c8; box-shadow: 0 0 0 3px rgba(67,121,214,.1); }
.inline-field { display: flex; align-items: stretch; gap: 7px; }
.inline-field input { min-width: 0; flex: 1 1 auto; }
.lookup-button { color: var(--blue); white-space: nowrap; }
.lookup-button:disabled { cursor: wait; opacity: .55; }
.lookup-status { min-height: 15px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.lookup-status.loading { color: #2d5da9; }
.lookup-status.success { color: #08756a; }
.lookup-status.error { color: #a13b3b; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.toast { position: fixed; z-index: 30; right: 24px; bottom: 24px; max-width: min(360px, calc(100vw - 48px)); padding: 13px 16px; border-radius: 10px; color: var(--white); background: var(--navy); box-shadow: var(--shadow); font-size: 12px; }

@media (max-width: 1050px) {
  .sidebar { width: 225px; flex-basis: 225px; }
  .topbar, .content { padding-left: 25px; padding-right: 25px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .panel-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .sidebar { position: fixed; z-index: 15; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu { display: block; }
  .topbar { min-height: 78px; padding: 15px 17px; }
  .page-heading .eyebrow { display: none; }
  .page-heading h1 { font-size: 19px; }
  .top-actions { margin-left: auto; }
  .search-box { width: 35px; padding: 9px; justify-content: center; }
  .search-box input { display: none; }
  .primary-button { padding: 9px 11px; font-size: 12px; }
  .primary-button span { display: none; }
  .icon-button { display: none; }
  .content { padding: 25px 17px 42px; }
  .welcome { display: block; }
  .welcome h2 { font-size: 24px; }
  .date-label { display: block; margin-top: 12px; }
  .stats-grid { gap: 9px; }
  .stat-card { padding: 14px; }
  .stat-value { margin-top: 11px; font-size: 24px; }
  .stat-icon { width: 29px; height: 29px; font-size: 14px; }
  .panel-header { padding: 15px; }
  .panel-body { padding: 4px 15px 12px; }
  .section-toolbar { align-items: flex-start; }
  .section-toolbar .primary-button { flex: 0 0 auto; }
  .two-col, .form-grid { grid-template-columns: 1fr; }
  .form-field.full { grid-column: auto; }
  #record-form, .modal-header { padding-left: 18px; padding-right: 18px; }
  .modal-footer { margin-top: 17px; }
}
