:root {
  color-scheme: light;
  --canvas: #fafafa;
  --surface: #ffffff;
  --ink: #18181b;
  --muted: #71717a;
  --line: #e4e4e7;
  --soft: #f4f4f5;
  --focus: #18181b;
  --radius: 9px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
a { color: inherit; text-decoration: none; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: 30px; letter-spacing: -0.04em; }
h2 { margin-bottom: 0; font-size: 15px; letter-spacing: -0.01em; }
.muted { color: var(--muted); font-size: 13px; }
.eyebrow { margin-bottom: 8px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .13em; }
.brand-mark { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 10px; background: transparent; font-size: 13px; font-weight: 800; letter-spacing: -.05em; overflow: hidden; }
.brand-logo { display: block; width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.small-mark { width: 28px; height: 28px; border-radius: 7px; font-size: 10px; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.nav-icon { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.is-hidden { display: none !important; }
.global-loader { position: fixed; z-index: 100; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(250,250,250,.72); backdrop-filter: blur(2px); }
.global-loader.is-hidden { display: none; }
.loader-card { display: flex; min-width: 150px; align-items: center; justify-content: center; gap: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 10px 24px rgba(0,0,0,.08); color: var(--muted); font-size: 12px; padding: 13px 16px; }
.loader-ring { width: 15px; height: 15px; border: 2px solid #d4d4d8; border-right-color: var(--ink); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.portal-shell { min-height: 100vh; }
.side-panel { position: fixed; z-index: 20; display: flex; width: 244px; height: 100vh; flex-direction: column; border-right: 1px solid var(--line); background: var(--surface); padding: 22px 14px 16px; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 28px; font-size: 14px; font-weight: 700; letter-spacing: -.02em; }
.side-navigation { display: flex; flex: 1; flex-direction: column; gap: 3px; }
.nav-label { margin: 17px 10px 7px; color: #a1a1aa; font-size: 10px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.side-link { display: flex; align-items: center; gap: 10px; border-radius: 6px; color: #52525b; font-size: 13px; padding: 9px 10px; transition: background .15s, color .15s; }
.side-link:hover, .side-link:focus, .side-link.active { background: var(--soft); color: var(--ink); outline: none; }
.side-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; padding: 14px 10px 0; }
.status-dot { display: inline-block; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%; background: #18181b; vertical-align: 1px; }
.main-frame { min-height: 100vh; margin-left: 244px; }
.top-bar { display: flex; height: 64px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(250,250,250,.88); padding: 0 34px; }
.top-title { color: #52525b; font-size: 13px; font-weight: 600; }
.top-user { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: 12px; }
.profile-chip { display: inline-flex; align-items: center; gap: 6px; color: #52525b; }
.profile-chip:hover { color: var(--ink); }
.page-content { max-width: 1320px; margin: 0 auto; padding: 0 34px 64px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 28px; }
.page-heading-actions { display: flex; align-items: center; gap: 9px; }
.tab-pills { display: inline-flex; gap: 4px; margin-bottom: 18px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); }
.tab-pill { border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; padding: 8px 13px; }
.tab-pill:hover, .tab-pill.is-active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 22px; }
.metric-panel, .content-panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.metric-panel { min-height: 112px; padding: 18px; }
.metric-panel span { display: block; color: var(--muted); font-size: 12px; }
.metric-panel strong { display: block; margin-top: 18px; font-size: 25px; letter-spacing: -.04em; }
.heading-skeleton { margin: 0 0 8px !important; width: 280px; }
.content-panel { margin-bottom: 18px; padding: 20px; }
.api-docs-panel { padding: 0; overflow: hidden; }
.api-docs-frame { display: block; width: 100%; height: calc(100vh - 190px); min-height: 680px; border: 0; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 17px; }
.panel-heading .muted { margin: 5px 0 0; }
.panel-actions { display: flex; align-items: center; gap: 9px; }
.panel-actions .text-field { min-width: 145px; width: auto; }
.date-range-input { cursor: pointer; min-width: 205px !important; }
.daterangepicker { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); box-shadow: 0 12px 30px rgba(0,0,0,.12); font-family: inherit; }
.daterangepicker .ranges li { color: var(--ink); }
.daterangepicker .ranges li:hover { background: var(--soft); color: var(--ink); }
.daterangepicker .ranges li.active, .daterangepicker td.active, .daterangepicker td.active:hover { background: var(--ink); color: var(--surface); }
.daterangepicker td.in-range { background: var(--soft); color: var(--ink); }
.daterangepicker td.available:hover, .daterangepicker th.available:hover { background: var(--soft); color: var(--ink); }
.daterangepicker th, .daterangepicker td { color: var(--ink); }
.daterangepicker td.off, .daterangepicker td.off.in-range { background: var(--surface); color: #a1a1aa; }
.daterangepicker .calendar-table { border-color: var(--line); background: var(--surface); }
.daterangepicker .drp-buttons { border-top-color: var(--line); }
.daterangepicker .drp-selected { color: var(--muted); }
.daterangepicker .applyBtn { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.daterangepicker .cancelBtn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.daterangepicker .cancelBtn:hover { background: var(--soft); }
.split-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.company-info-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.company-info-grid div { display: flex; flex-direction: column; gap: 7px; border-right: 1px solid var(--line); padding-right: 16px; }
.company-info-grid div:last-child { border-right: 0; }
.company-info-grid strong { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.chart-panel { min-height: 280px; }
.chart-wrap { position: relative; height: 250px; }
.table-scroll { overflow-x: auto; }
.data-grid { width: 100%; border-collapse: collapse; font-size: 12px; text-align: left; }
.data-grid th { border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; padding: 10px 12px; text-transform: uppercase; white-space: nowrap; }
.data-grid td { border-bottom: 1px solid var(--line); max-width: 360px; padding: 12px; vertical-align: top; }
.data-grid tr:last-child td { border-bottom: 0; }
.data-grid tr:hover td { background: #fafafa; }
.table-toolbar, .table-pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.table-toolbar { margin-bottom: 12px; }
.table-toolbar .text-field { width: auto; min-width: 130px; }
.table-filter { flex: 1; max-width: 330px; }
.table-page-size { cursor: pointer; }
.table-pagination { margin-top: 14px; }
.table-pagination > div { display: flex; align-items: center; gap: 8px; }
.table-pagination .secondary-action:disabled { cursor: not-allowed; opacity: .45; }
.table-page-label { color: var(--muted); font-size: 12px; white-space: nowrap; }
.table-sort { border: 0; background: transparent; color: inherit; cursor: pointer; font: inherit; font-size: inherit; font-weight: inherit; letter-spacing: inherit; padding: 0; text-align: left; text-transform: inherit; }
.table-sort:hover, .table-sort.is-sorted { color: var(--ink); }
.table-empty { color: var(--muted); padding: 28px !important; text-align: center; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stack-form { display: flex; flex-direction: column; gap: 8px; margin-top: 26px; }
.field-label { color: #3f3f46; font-size: 12px; font-weight: 600; }
.toggle-field { display: flex; align-items: center; margin-top: 6px; }
.toggle-input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.toggle-label { display: inline-flex; align-items: center; gap: 9px; color: #3f3f46; cursor: pointer; font-size: 12px; font-weight: 600; }
.toggle-control { position: relative; display: inline-block; width: 40px; height: 22px; border: 1px solid #d4d4d8; border-radius: 999px; background: #e4e4e7; transition: background .15s, border-color .15s; }
.toggle-control::after { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.18); content: ''; transition: transform .15s; }
.toggle-input:checked + .toggle-label .toggle-control { border-color: var(--ink); background: var(--ink); }
.toggle-input:checked + .toggle-label .toggle-control::after { transform: translateX(18px); }
.toggle-input:focus-visible + .toggle-label .toggle-control { box-shadow: 0 0 0 3px rgba(24,24,27,.12); }
.text-field { min-height: 38px; width: 100%; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); font: inherit; font-size: 13px; padding: 8px 10px; outline: none; }
.text-field:focus { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(24,24,27,.1); }
.select2-container { font-size: 13px; }
.select2-container--default .select2-selection--single { height: 38px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.select2-container--default .select2-selection--single .select2-selection__rendered { color: var(--ink); line-height: 36px; padding-left: 10px; }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 36px; right: 7px; }
.select2-container--default.select2-container--focus .select2-selection--single, .select2-container--default.select2-container--open .select2-selection--single { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(24,24,27,.1); }
.select2-dropdown { border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 10px 24px rgba(0,0,0,.08); overflow: hidden; }
.select2-container--default .select2-results__option { color: var(--ink); padding: 9px 10px; }
.select2-container--default .select2-results__option--highlighted[aria-selected] { background: var(--soft); color: var(--ink); }
.table-toolbar .select2-container { width: auto !important; min-width: 130px; }
.primary-action, .secondary-action, .text-action, .icon-action { border: 0; border-radius: 6px; cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; }
.primary-action { min-height: 38px; background: #18181b; color: white; padding: 0 14px; }
.primary-action:hover { background: #27272a; }
.secondary-action { border: 1px solid var(--line); background: #fff; color: #3f3f46; padding: 8px 11px; }
.secondary-action:hover { background: var(--soft); }
.secondary-action:disabled { cursor: not-allowed; opacity: .55; }
.table-action { display: inline-flex; align-items: center; gap: 6px; }
.button-icon { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.action-add { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.action-add:hover { background: #dbeafe; }
.action-save { background: #f0f9ff; border-color: #bae6fd; color: #0369a1; }
.action-save:hover { background: #e0f2fe; }
.action-edit { background: #f5f3ff; border-color: #ddd6fe; color: #6d28d9; }
.action-edit:hover { background: #ede9fe; }
.action-view { background: #f4f4f5; border-color: #d4d4d8; color: #27272a; }
.action-view:hover { background: #e4e4e7; }
.action-status-on { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.action-status-on:hover { background: #dcfce7; }
.action-status-off { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.action-status-off:hover { background: #fee2e2; }
.action-test { background: #fff7ed; border-color: #fed7aa; color: #c2410c; }
.action-test:hover { background: #ffedd5; }
.action-security { background: #f0fdfa; border-color: #99f6e4; color: #0f766e; }
.action-security:hover { background: #ccfbf1; }
.text-action { background: transparent; color: var(--muted); padding: 5px 0; }
.text-action:hover { color: var(--ink); }
.icon-action { display: none; background: transparent; color: var(--ink); font-size: 18px; padding: 4px 8px; }
#message { margin-bottom: 14px; }
.portal-toast-stack { position: fixed; z-index: 80; top: 78px; right: 24px; display: flex; width: min(390px, calc(100vw - 32px)); flex-direction: column; gap: 10px; pointer-events: none; }
.portal-toast { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 12px 28px rgba(0,0,0,.12); font-size: 13px; line-height: 1.4; padding: 13px 14px; pointer-events: auto; animation: toast-in .18s ease-out; }
.toast-success { border-color: #bbf7d0; color: #166534; }
.toast-error { border-color: #fecaca; color: #b91c1c; }
.toast-close { border: 0; background: transparent; color: inherit; cursor: pointer; font: inherit; font-size: 18px; line-height: 1; padding: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.alert-box { border: 1px solid var(--line); border-radius: 6px; background: var(--soft); color: #3f3f46; font-size: 12px; padding: 10px 12px; }
.alert-success { border-color: #bbf7d0; background: #f0fdf4; color: #166534; }
.alert-error { border-color: #fecaca; background: #fef2f2; color: #b91c1c; }
.portal-confirm-backdrop { position: fixed; z-index: 60; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.28); padding: 20px; }
.portal-confirm-dialog { width: min(100%, 420px); border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: 0 18px 45px rgba(0,0,0,.18); }
.portal-confirm-body { padding: 22px; }
.portal-confirm-body h2 { margin-bottom: 8px; }
.portal-confirm-body p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.portal-confirm-actions { display: flex; justify-content: flex-end; gap: 9px; border-top: 1px solid var(--line); padding: 14px 22px; }
.danger-action { border: 1px solid #b91c1c; border-radius: 6px; background: #b91c1c; color: #fff; cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; padding: 8px 11px; }
.danger-action:hover { background: #991b1b; border-color: #991b1b; }
.skeleton-line, .skeleton-block { display: block; overflow: hidden; position: relative; border-radius: 4px; background: #f0f0f1; }
.skeleton-line { height: 12px; width: 72%; }
.skeleton-block { height: 29px; width: 58%; margin-top: 18px; }
.skeleton-line::after, .skeleton-block::after { position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.8), transparent); content: ""; transform: translateX(-100%); animation: shimmer 1.3s infinite; }
.loading-row td { padding: 16px 12px; }
@keyframes shimmer { 100% { transform: translateX(100%); } }
.auth-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at 50% -20%, #fff 0, var(--canvas) 50%); }
.auth-card { width: min(100%, 390px); border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 12px 32px rgba(0,0,0,.06); padding: 34px; }
.auth-card .brand-mark { margin-bottom: 26px; }
.auth-card h1 { font-size: 25px; }
.auth-card .muted { line-height: 1.6; }
.drawer-backdrop { position: fixed; z-index: 40; inset: 0; display: none; background: rgba(0,0,0,.28); }
.drawer-backdrop.is-open { display: block; }
.drawer-panel { position: fixed; z-index: 50; top: 0; right: 0; display: flex; width: min(560px, 100%); height: 100vh; flex-direction: column; transform: translateX(100%); border-left: 1px solid var(--line); background: var(--surface); box-shadow: -12px 0 32px rgba(0,0,0,.1); transition: transform .2s ease; }
.drawer-panel.is-open { transform: translateX(0); }
.drawer-header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 20px 22px; }
.drawer-header h2 { font-size: 17px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 22px; }
.drawer-actions { display: flex; justify-content: flex-end; gap: 9px; border-top: 1px solid var(--line); padding: 14px 22px; }
.close-action { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 22px; line-height: 1; }
.drawer-form { display: flex; flex-direction: column; gap: 8px; }

@media (max-width: 900px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-grid { grid-template-columns: 1fr; }
  .profile-grid { grid-template-columns: 1fr; }
  .company-info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .side-panel { transform: translateX(-100%); transition: transform .2s ease; }
  .side-panel.is-open { transform: translateX(0); }
  .mobile-backdrop { display: none; position: fixed; z-index: 10; inset: 0; background: rgba(0,0,0,.24); }
  .mobile-backdrop.is-open { display: block; }
  .main-frame { margin-left: 0; }
  .top-bar { height: 58px; padding: 0 16px; }
  .icon-action { display: block; }
  .top-user { gap: 9px; }
  #identity { display: none; }
  .profile-chip span { display: none; }
  .page-content { padding: 0 16px 48px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .metric-panel { min-height: 98px; padding: 14px; }
  .metric-panel strong { margin-top: 13px; font-size: 21px; }
  .content-panel { padding: 15px; }
  .company-info-grid { grid-template-columns: 1fr; }
  .company-info-grid div { border-right: 0; border-bottom: 1px solid var(--line); padding: 0 0 12px; }
  .company-info-grid div:last-child { border-bottom: 0; padding-bottom: 0; }
  .panel-actions { align-items: stretch; flex-direction: column; }
  .panel-actions .text-field { min-width: 0; width: 100%; }
  .page-heading { align-items: stretch; flex-direction: column; gap: 16px; }
  .page-heading-actions, .page-heading-actions .text-field { width: 100%; }
  .portal-toast-stack { top: 72px; right: 16px; width: calc(100vw - 32px); }
  .date-range-input { min-width: 0 !important; }
  .table-toolbar, .table-pagination { align-items: stretch; flex-direction: column; }
  .table-toolbar .text-field { width: 100%; max-width: none; }
  .table-pagination { gap: 10px; }
  .table-pagination > div { justify-content: space-between; }
  .form-grid { grid-template-columns: 1fr; }
}
