:root {
  --navy-950: #1e3c72;
  --navy-900: #2a5298;
  --navy-800: #334f86;
  --blue-600: #3a50b0;
  --blue-500: #4364f7;
  --teal-500: #d6a619;
  --gold: #efbe28;
  --surface: #ffffff;
  --background: #e7e7e7;
  --border: #dce6ef;
  --text: #142536;
  --muted: #687a8c;
  --danger: #c43d4f;
  --shadow: 0 12px 36px rgba(30, 60, 114, .12);
  --radius: 16px;
  --font: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; min-height: 100vh; background: var(--background); color: var(--text); font-family: var(--font); font-size: 14px; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.site-header { position: relative; z-index: 10; box-shadow: 0 3px 10px rgba(25, 37, 72, .16); }
.topbar { height: 66px; padding: 0 28px; background: #4056b8; color: white; display: flex; align-items: center; gap: 44px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 190px; }
.brand-mark, .login-icon { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; background: rgba(255,255,255,.14); box-shadow: 0 7px 18px rgba(12, 33, 71, .2); }
.brand-mark img, .login-icon img { width: 28px; height: 28px; }
.brand strong, .brand small { display: block; line-height: 1.15; }
.brand strong { color: var(--gold); font-size: 18px; letter-spacing: .01em; }
.brand small { color: rgba(255,255,255,.75); margin-top: 2px; font-size: 10px; text-transform: uppercase; letter-spacing: .13em; }
.navstrip { min-height: 54px; padding: 0 28px; display: flex; align-items: center; justify-content: flex-end; gap: 20px; background: white; }
.topnav { display: flex; gap: 4px; align-items: center; }
.topnav a { padding: 10px 13px; border-radius: 7px; color: #4e4e4e; font-weight: 600; }
.topnav a span, .navstrip .link-button span { margin-right: 5px; color: var(--gold); font-size: 17px; }
.topnav a:hover, .topnav a.active { color: var(--navy-900); background: #f4f5fb; }
.user-menu { margin-left: auto; display: flex; align-items: center; gap: 10px; color: #d9e5ef; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--navy-800); font-weight: 700; }
.user-name { max-width: 180px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.link-button { border: 0; background: none; color: #4e4e4e; cursor: pointer; padding: 8px; font-weight: 600; }
.link-button:hover { color: var(--navy-900); }

.page-shell { width: min(1540px, calc(100% - 48px)); margin: 0 auto; padding: 34px 0 50px; }
.page-header { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: clamp(25px, 3vw, 34px); letter-spacing: -.035em; }
h2 { margin-bottom: 5px; font-size: 17px; letter-spacing: -.01em; }
.page-header p, .table-toolbar p, .modal-card > p { color: var(--muted); margin-bottom: 0; }
.eyebrow { display: block; margin-bottom: 8px; color: #145a9e; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .14em; }
.header-actions, .bulk-actions, .modal-actions { display: flex; align-items: center; gap: 10px; }

.btn { border: 1px solid transparent; border-radius: 10px; min-height: 40px; padding: 0 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; cursor: pointer; transition: transform .15s, box-shadow .15s, background .15s; }
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.btn-primary { color: white; background: linear-gradient(to right, var(--blue-600), var(--blue-500)); box-shadow: 0 8px 20px rgba(58, 80, 176, .24); }
.btn-primary:hover { box-shadow: 0 10px 24px rgba(23, 116, 209, .3); }
.btn-secondary { border-color: var(--border); color: var(--navy-800); background: white; }
.btn-danger { border-color: #f3c8cf; color: var(--danger); background: #fff7f8; }
.btn-block { width: 100%; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--border); border-radius: 9px; display: inline-grid; place-items: center; color: var(--navy-800); background: white; font-size: 22px; cursor: pointer; }

.workspace-grid { display: grid; grid-template-columns: 292px minmax(0, 1fr); gap: 22px; align-items: start; }
.card, .metric-card { border: 1px solid rgba(218, 218, 218, .95); background: var(--surface); border-radius: var(--radius); box-shadow: 0 4px 12px rgba(45, 45, 45, .08); }
.filters { position: sticky; top: 20px; padding: 20px; max-height: calc(100vh - 40px); overflow: auto; }
.card-heading, .table-toolbar, .modal-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.card-heading { margin-bottom: 19px; }
.card-heading h2 { margin: 0; }
.badge { min-width: 25px; height: 25px; display: grid; place-items: center; border-radius: 999px; color: var(--blue-600); background: #eaf4ff; font-weight: 800; font-size: 12px; }
.field { display: grid; gap: 7px; margin-bottom: 17px; color: #415568; font-size: 12px; font-weight: 700; }
.field input, .field select, .field textarea, .inline-select select { width: 100%; border: 1px solid var(--border); border-radius: 9px; padding: 10px 11px; background: white; color: var(--text); outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(37, 136, 232, .12); }
.field select[multiple] { min-height: 92px; }
.field textarea { resize: vertical; }
.field-label { display: block; }
.search-input { position: relative; }
.search-input span { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 18px; }
.search-input input { padding-left: 35px; }
.check-list { display: grid; gap: 5px; max-height: 178px; overflow: auto; padding: 3px 1px; }
.check-item { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 8px; color: #3c5062; font-weight: 500; cursor: pointer; }
.check-item:hover { background: #f4f8fc; }
.check-item input, .category-option input {
  width: 16px;
  height: 16px;
  margin: 0;
  flex: 0 0 16px;
  accent-color: var(--blue-600);
}
.check-item .color-dot { margin-left: 2px; }
.color-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.inline-select { display: flex; align-items: center; gap: 7px; margin-top: 8px; color: var(--muted); font-size: 11px; }
.inline-select select { padding: 7px; font-size: 11px; }
.switch-row { display: flex; align-items: center; gap: 9px; color: #415568; font-size: 12px; font-weight: 600; cursor: pointer; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch { width: 36px; height: 21px; padding: 3px; border-radius: 99px; background: #b7c6d4; transition: .2s; }
.switch::after { content: ""; display: block; width: 15px; height: 15px; border-radius: 50%; background: white; box-shadow: 0 1px 4px rgba(0,0,0,.18); transition: .2s; }
.switch-row input:checked + .switch { background: var(--teal-500); }
.switch-row input:checked + .switch::after { transform: translateX(15px); }
.filter-clear { margin-top: 18px; }

.results-area { min-width: 0; }
.metrics-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.metric-card { padding: 17px 19px; display: flex; align-items: center; gap: 13px; box-shadow: 0 8px 26px rgba(17, 50, 76, .06); }
.metric-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; font-size: 17px; font-weight: 800; }
.metric-icon.blue { background: #e9f4ff; color: var(--blue-600); }
.metric-icon.green { background: #e7f8f4; color: #0a8f7f; }
.metric-icon.violet { background: #f0eafe; color: #7650c7; }
.metric-card small, .metric-card strong { display: block; }
.metric-card small { margin-bottom: 3px; color: var(--muted); font-size: 11px; }
.metric-card strong { font-size: 23px; letter-spacing: -.03em; }

.table-card { overflow: hidden; }
.table-toolbar { min-height: 78px; padding: 17px 21px; border-bottom: 1px solid var(--border); }
.table-toolbar h2 { margin-bottom: 3px; }
.table-toolbar p { font-size: 12px; }
.bulk-actions { color: var(--muted); font-size: 12px; }
.table-scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 14px; border-bottom: 1px solid #e8eef4; text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; z-index: 1; color: #6b7d8d; background: #f8fafc; font-size: 10px; text-transform: uppercase; letter-spacing: .085em; white-space: nowrap; }
td { color: #34495b; font-size: 12px; }
tbody tr:hover { background: #f9fcfe; }
.contact-name { color: var(--navy-900); font-weight: 700; }
.contact-email, .subtle { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { padding: 4px 7px; border-radius: 99px; color: var(--navy-800); background: #eaf3fa; font-size: 10px; font-weight: 700; }
.origin-cell { max-width: 180px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.empty-state { padding: 54px 20px; text-align: center; color: var(--muted); }
.pagination { min-height: 61px; padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; }
.pagination div { display: flex; gap: 7px; }

.modal { width: min(520px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 17px; background: transparent; box-shadow: 0 25px 70px rgba(5, 25, 42, .3); }
.modal::backdrop { background: rgba(5, 22, 37, .52); backdrop-filter: blur(3px); }
.modal-card { padding: 24px; background: white; border-radius: 17px; }
.modal-header { margin-bottom: 14px; }
.modal-header h2 { font-size: 21px; }
.modal-actions { justify-content: flex-end; margin-top: 22px; }
.category-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 17px 0; }
.category-option { padding: 10px; display: flex; align-items: center; gap: 9px; border: 1px solid var(--border); border-radius: 9px; cursor: pointer; }
.form-row { display: grid; grid-template-columns: 120px 1fr; gap: 18px; align-items: center; }

.categories-card { overflow: hidden; }
.categories-card .table-toolbar { padding: 20px 22px; }
.category-name { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--navy-900); }
.status-pill { padding: 4px 8px; border-radius: 99px; font-size: 10px; font-weight: 800; background: #e4f7f1; color: #087564; }
.status-pill.off { color: #748596; background: #eef2f5; }
.align-right { text-align: right; }
.row-actions { display: flex; justify-content: flex-end; gap: 7px; }

.login-body { background: linear-gradient(to right bottom, var(--navy-950), var(--navy-900)); }
.login-body::before { content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .085; background-image: radial-gradient(circle at 20% 25%, white 0 2px, transparent 3px), radial-gradient(circle at 75% 60%, white 0 2px, transparent 3px); background-size: 74px 74px, 106px 106px; transform: rotate(-8deg) scale(1.15); }
.login-page-shell { width: min(1180px, calc(100% - 48px)); min-height: 100vh; padding: 0; position: relative; z-index: 1; }
.login-layout { min-height: 100vh; display: grid; grid-template-columns: 1.2fr .8fr; align-items: center; gap: clamp(45px, 8vw, 120px); }
.login-intro { max-width: 650px; }
.login-intro .eyebrow { color: var(--gold); }
.login-intro h1 { max-width: 620px; font-size: clamp(36px, 5vw, 58px); color: white; line-height: 1.08; text-shadow: 0 3px 18px rgba(8,24,55,.18); }
.login-intro > p { max-width: 560px; color: rgba(255,255,255,.78); font-size: 17px; line-height: 1.65; }
.feature-row { margin-top: 14px; color: rgba(255,255,255,.88); font-weight: 600; }
.feature-row span { margin-right: 9px; color: var(--gold); }
.login-card { padding: 34px; border: 1px solid rgba(255,255,255,.6); border-radius: 16px; background: white; box-shadow: 0 24px 70px rgba(8, 28, 64, .3); }
.login-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 24px; }
.login-card .login-icon { flex: 0 0 auto; background: linear-gradient(to right bottom, var(--navy-950), var(--navy-900)); }
.login-card h2 { margin: 0; color: var(--navy-950); font-size: 25px; }
.login-brand div > span { display: block; margin-top: 2px; color: var(--gold); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.login-message { margin-bottom: 5px; }
.login-card > p, .login-card > small { color: var(--muted); }
.login-card label { display: grid; gap: 7px; margin-top: 17px; color: #415568; font-size: 12px; font-weight: 700; }
.login-card input { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 12px; outline: none; }
.login-card .btn { margin: 22px 0 14px; min-height: 46px; text-transform: uppercase; letter-spacing: .04em; }
.login-footer { display: block; text-align: center; }
.alert { padding: 10px 12px; margin: 13px 0; border-radius: 8px; font-size: 12px; }
.alert.error { color: #9e2e3f; background: #fff0f2; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 30; max-width: 380px; padding: 13px 16px; border-radius: 10px; color: white; background: var(--navy-900); box-shadow: 0 12px 35px rgba(0,0,0,.22); transform: translateY(30px); opacity: 0; pointer-events: none; transition: .2s; }
.toast.show { transform: none; opacity: 1; }
.toast.error { background: var(--danger); }
.skeleton-line { display: block; height: 15px; border-radius: 6px; background: linear-gradient(90deg, #edf2f6 25%, #f8fafb 45%, #edf2f6 65%); background-size: 300% 100%; animation: shine 1.3s infinite; }
@keyframes shine { to { background-position: -150% 0; } }

@media (max-width: 980px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .filters { position: static; max-height: none; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .metrics-grid .metric-card:last-child { grid-column: 1 / -1; }
  .login-layout { grid-template-columns: 1fr; padding-top: 30px; }
  .login-intro { display: none; }
  .login-card { width: min(440px, 100%); margin: auto; }
}
@media (max-width: 680px) {
  .topbar, .navstrip { padding-left: 16px; padding-right: 16px; }
  .navstrip { justify-content: space-between; }
  .brand { min-width: auto; }
  .brand > span:last-child, .user-name { display: none; }
  .topnav { margin-left: auto; }
  .user-menu { margin-left: 0; }
  .page-shell { width: min(100% - 28px, 1540px); padding-top: 24px; }
  .page-header { align-items: stretch; flex-direction: column; }
  .header-actions .btn { flex: 1; }
  .metrics-grid { grid-template-columns: 1fr; }
  .metrics-grid .metric-card:last-child { grid-column: auto; }
  .table-toolbar { align-items: flex-start; flex-direction: column; }
  .category-grid { grid-template-columns: 1fr; }
}
