/* Shared visual system: neutral surfaces, readable glass controls, document scrolling. */
:root, html[data-theme=light] {
  --bg:#f5f5f7; --bg-soft:#eceef1; --card:#fff; --card-2:#f8f9fb;
  --text:#1d1d1f; --muted:#626873; --border:#e2e5ea; --border-strong:#c5cbd4;
  --accent:#0069d1; --accent-2:#368bea; --accent-soft:#e9f2ff;
  --sidebar:#f1f3f7; --sidebar-soft:#e8edf4;
  --ok:#19734b; --warn:#906019; --bad:#b3333d;
  --glass:rgba(255,255,255,.78); --glass-edge:rgba(255,255,255,.95);
  --shadow-soft:0 4px 20px rgba(31,42,63,.045);
}
html[data-theme=dark] {
  --bg:#141518; --bg-soft:#202226; --card:#222428; --card-2:#292c31;
  --text:#f3f4f6; --muted:#acb2bd; --border:#353a42; --border-strong:#535a66;
  --accent:#80baff; --accent-2:#a1cdff; --accent-soft:#223851;
  --sidebar:#1a1c20; --sidebar-soft:#2b3038;
  --ok:#77caa0; --warn:#e6b568; --bad:#ff9ca4;
  --glass:rgba(39,43,50,.88); --glass-edge:rgba(255,255,255,.09);
  --shadow-soft:0 4px 20px rgba(0,0,0,.14);
}
html[data-accent=teal] { --accent:#157365; --accent-2:#288b7a; --accent-soft:#e7f3ee; }
html[data-accent=rose] { --accent:#a63d64; --accent-2:#ba577b; --accent-soft:#f8edf2; }
html[data-theme=dark][data-accent=teal] { --accent:#82d3c2; --accent-soft:#203c38; }
html[data-theme=dark][data-accent=rose] { --accent:#f1a8c2; --accent-soft:#422c36; }
body {
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,sans-serif;
  background:radial-gradient(ellipse at 80% 0%,color-mix(in srgb,var(--accent) 5%,transparent),transparent 55%),var(--bg);
  color:var(--text);
}
.main { max-width:1800px; }
.topbar, .toolbar-row, .cc-dialog-footer { position:static; top:auto; bottom:auto; }
.topbar { position:relative; backdrop-filter:none; }
.topbar-title { min-width:0; align-items:center; }
.toolbar-row { flex-wrap:wrap; background:none; backdrop-filter:none; }
.sidebar {
  background:var(--glass); color:var(--text); border-right:1px solid var(--border);
  backdrop-filter:blur(24px) saturate(135%); -webkit-backdrop-filter:blur(24px) saturate(135%);
}
.sidebar .brand strong { color:var(--text); }
.sidebar .brand span, .nav-label, .settings-shortcut small, .sidebar-user small { color:var(--muted); }
.brand-mark, .sidebar .brand-mark {
  background:linear-gradient(150deg,#4b98ea,#0061c8); color:#fff;
  border:1px solid #ffffff60; box-shadow:inset 0 1px 0 #ffffff70,0 5px 12px #0069d120;
}
.nav-item, .nav-subitem, .settings-shortcut, .sidebar-user { color:var(--muted); }
.nav-item .nav-glyph { color:inherit; }
.nav-item:hover, .nav-subitem:hover, .settings-shortcut:hover { background:var(--card-2); color:var(--text); }
.nav-item.active {
  background:var(--accent-soft); color:var(--accent); border:1px solid color-mix(in srgb,var(--accent) 12%,var(--border));
  box-shadow:inset 0 1px 0 var(--glass-edge),0 2px 6px #00000004;
}
.nav-item.active .nav-glyph { color:var(--accent); }
.nav-sub { border-left-color:var(--border-strong); }
.nav-subitem.active { background:var(--accent-soft); color:var(--accent); }
.sidebar-footer { border-top-color:var(--border); }
.settings-shortcut, .sidebar-collapse { border-color:var(--border); }
.sidebar-collapse, .user-avatar { background:var(--card-2); color:var(--muted); }
.sidebar-close { display:none; }
.primary-action, .secondary-action, .icon-button, .refresh-button, .record-action, .filter-button, .filter-chip {
  border-radius:12px; transition:background .16s,box-shadow .16s,border-color .16s,transform .16s;
}
.secondary-action, .icon-button, .refresh-button, .record-action, .filter-button, .filter-chip {
  color:var(--text); background:linear-gradient(160deg,var(--glass-edge),transparent),var(--glass);
  border:1px solid var(--border); box-shadow:inset 0 1px 0 var(--glass-edge),0 2px 5px #00000004;
  backdrop-filter:blur(12px); -webkit-backdrop-filter:blur(12px);
}
.primary-action {
  background:linear-gradient(180deg,color-mix(in srgb,var(--accent) 78%,white),var(--accent));
  color:#fff; border:1px solid color-mix(in srgb,var(--accent) 88%,black);
  box-shadow:inset 0 1px 0 #ffffff50,0 3px 8px color-mix(in srgb,var(--accent) 18%,transparent);
}
html[data-theme=dark] .primary-action { color:#102237; }
button:active:not(:disabled) { transform:translateY(1px); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline:3px solid color-mix(in srgb,var(--accent) 65%,transparent); outline-offset:3px;
}
.secondary-action:hover, .icon-button:hover, .record-action:hover { background:var(--accent-soft); border-color:var(--border-strong); }
.record-action.danger { color:var(--bad); }
.panel-card, .large-card, .project-card, .idea-card, .server-card, .domain-card-rich,
.mailbox-settings-card, .affiliate-card, .accounting-company-card, .kpi-card {
  border-radius:18px; box-shadow:var(--shadow-soft); border-color:var(--border);
}
.dashboard-hero {
  background:linear-gradient(120deg,var(--glass),color-mix(in srgb,var(--accent-soft) 55%,var(--card)));
  border:1px solid var(--border); box-shadow:inset 0 1px 0 var(--glass-edge),var(--shadow-soft);
  border-radius:22px;
}
.dashboard-hero::after { display:none; }
.dashboard-hero h2 { color:var(--text); }
.dashboard-hero p { color:var(--muted); }
.dashboard-hero .hero-date { color:var(--accent); }
.dashboard-hero .primary-action { background:linear-gradient(180deg,color-mix(in srgb,var(--accent) 78%,white),var(--accent)); border-color:var(--accent); color:#fff; }
html[data-theme=dark] .dashboard-hero .primary-action { color:#102237; }
.dashboard-hero .secondary-action { background:var(--glass); color:var(--text); border-color:var(--border); }
.balance-card { background:linear-gradient(130deg,#1b334c,#294c70); color:#fff; }
.ksef-card { background:var(--card); border:1px solid var(--border); border-radius:16px; }
.ksef-card.has-new { background:color-mix(in srgb,var(--warn) 6%,var(--card)); border-color:color-mix(in srgb,var(--warn) 30%,var(--border)); }
.ksef-card:hover, .ksef-card:focus-visible, .ksef-card.selected { background:var(--accent-soft); border-color:var(--accent); transform:none; }
.table-shell { background:var(--card); border-radius:14px; }
.command-results { top:100%; right:0; max-width:100%; max-height:min(65dvh,600px); overflow-y:auto; }
.cc-dialog-footer { padding-bottom:max(18px,env(safe-area-inset-bottom)); }
.modal-panel, .cc-dialog { overscroll-behavior:contain; }
@media(min-width:1081px) {
  .sidebar { position:static; height:auto; max-height:none; align-self:stretch; overflow:visible; }
  .sidebar .nav { flex:0 0 auto; overflow:visible; }
}
@media(max-width:1080px) {
  .sidebar, .nav-open .sidebar {
    position:fixed; inset:0 auto 0 0; width:min(330px,calc(100vw - 44px)); max-width:none;
    height:100dvh; max-height:100dvh; min-height:0; overflow-y:auto;
    padding:calc(18px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
    overscroll-behavior:contain; -webkit-overflow-scrolling:touch;
    background:var(--glass); z-index:92; box-shadow:20px 0 70px #00000020;
    visibility:hidden; transform:translateX(-105%);
  }
  .nav-open .sidebar { visibility:visible; transform:translateX(0); }
  body.nav-open { overflow:hidden; }
  .sidebar .nav { flex:0 0 auto; overflow:visible; }
  .sidebar-head { flex-shrink:0; margin-bottom:18px; }
  .sidebar .brand { min-width:0; flex:1; }
  .sidebar .brand-copy { display:block; }
  .sidebar-collapse { display:none; }
  .sidebar-close { display:inline-flex; min-width:44px; min-height:44px; font-size:25px; }
  .nav-item, .nav-subitem, .settings-shortcut { min-height:44px; font-size:14px; }
  .nav-label { font-size:11px; margin-top:20px; }
  .sidebar-footer, .nav-open .sidebar-footer { margin-top:20px; margin-bottom:0; flex-shrink:0; }
  .nav-scrim { position:fixed; inset:0; z-index:91; background:#11182060; backdrop-filter:blur(3px); }
  .nav-open .mobile-bottom-nav { visibility:hidden; pointer-events:none; }
  .topbar { grid-template-columns:minmax(0,1fr) auto; gap:12px; }
  .topbar > .search-box { grid-column:1/-1; grid-row:2; width:100%; }
  .topbar-title { min-width:0; }
  .mobile-menu-button { min-height:44px; min-width:44px; border-radius:12px; flex-shrink:0; }
  .accounting-card-grid { grid-template-columns:repeat(auto-fit,minmax(min(100%,340px),1fr)); }
}
@media(max-width:800px) {
  .main { padding:0 16px calc(112px + env(safe-area-inset-bottom)); }
  .topbar { min-height:80px; padding-top:calc(16px + env(safe-area-inset-top)); gap:8px; }
  .topbar h1 { font-size:21px; max-width:none; }
  .topbar-title > div { min-width:0; }
  .topbar > .topbar-actions { gap:6px; }
  .topbar > .search-box { display:none; }
  .search-open .topbar > .search-box { display:flex; }
  .topbar-actions .icon-button { min-width:44px; width:44px; min-height:44px; height:44px; }
  .topbar-actions #notificationCenterBtn { display:none; }
  .global-add { min-height:44px; }
  .mobile-bottom-nav {
    inset:auto 12px calc(10px + env(safe-area-inset-bottom)); width:auto; height:auto; min-height:64px;
    padding:6px; border-radius:22px; gap:3px; background:var(--glass); border:1px solid var(--border);
    box-shadow:inset 0 1px 0 var(--glass-edge),0 8px 30px #18263a18;
    backdrop-filter:blur(24px) saturate(150%); -webkit-backdrop-filter:blur(24px) saturate(150%);
  }
  .mobile-bottom-nav button { min-height:50px; min-width:0; border-radius:16px; }
  .mobile-bottom-nav small { font-size:11px; }
  .toolbar-row, .ksef-toolbar, .action-row, .filter-row { flex-wrap:wrap; gap:10px; }
  .ksef-toolbar > * { min-width:0; max-width:100%; }
  .company-module-switcher { display:flex; flex-wrap:wrap; gap:4px; }
  .company-module-switcher button { flex:1; padding:12px 8px; min-height:44px; }
  .primary-action, .secondary-action, .record-action, .filter-button { min-height:44px; }
  .search-field input, select, textarea, input:not([type=checkbox]):not([type=radio]) { font-size:16px; }
  .topbar .search-box input { font-size:16px; }
  .panel-card, .large-card { padding:20px 16px; }
  .dashboard-hero { padding:24px 20px; }
  .dashboard-hero h2 { font-size:28px; }
  .hero-actions button { flex:1 1 130px; font-size:12px; }
  .card-header h2 { font-size:22px; }
  .module-heading h2 { font-size:25px; }
  .toast-region { bottom:calc(94px + env(safe-area-inset-bottom)); }
  .table-shell { max-width:100%; }
  .cc-dialog, .modal-panel { max-height:calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
}
@media(max-width:380px) {
  .main { padding-left:12px; padding-right:12px; }
  .mobile-bottom-nav { left:8px; right:8px; }
  .mobile-bottom-nav small { font-size:10px; }
  .kpi-card strong, .accounting-overview strong { font-size:25px; }
}
@media(max-height:500px) and (max-width:1080px) {
  .sidebar-user { display:none; }
  .nav-label { margin-top:12px; }
}
@media(prefers-reduced-transparency:reduce) {
  .sidebar, .nav-open .sidebar, .mobile-bottom-nav, .secondary-action, .icon-button { background:var(--card); backdrop-filter:none; }
}
@media(prefers-reduced-motion:reduce) {
  button { transition:none; } button:active { transform:none; }
}
/* Keep legacy icon and badge colors from reducing navigation contrast. */
.sidebar .brand { padding:0; gap:10px; }
.sidebar .brand span { font-size:10px; letter-spacing:0; }
.sidebar .nav-item > span:first-child, .sidebar .nav-glyph, .sidebar .nav-chevron { color:inherit; }
.sidebar .nav-item.active > span:first-child { color:var(--accent); }
.sidebar .nav-count {
  color:var(--accent)!important; background:var(--accent-soft);
  border-color:color-mix(in srgb,var(--accent) 22%,var(--border)); font-weight:650;
}
@media(max-width:1080px) {
  .sidebar-head { position:sticky; top:0; z-index:2; padding:8px; border-radius:14px; background:var(--card); box-shadow:var(--shadow-soft); }
}