/* ═══════════════════════════════════════════════════════════
   K697 Command Design System
   Shared across canteen · mess · battalion
   Identity: Tactical HUD — dark command rail, paper content
   ═══════════════════════════════════════════════════════════ */

:root,
body.theme-canteen {
  --font: "Cairo", Tahoma, Arial, sans-serif;
  --font-brand: "Orbitron", "Cairo", sans-serif;
  --font-num: "Orbitron", "Cairo", sans-serif;

  --primary: #c48a1a;
  --primary-dark: #9a6b10;
  --primary-light: #e8b44a;
  --accent: #f0a030;
  --accent-rgb: 240, 160, 48;
  --on-primary: #fffaf0;

  --success: #16a34a;
  --success-bg: #ecfdf5;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --info: #0284c7;
  --info-bg: #eff6ff;
  --violet: #7c3aed;
  --violet-bg: #f5f3ff;

  --bg-app: #f3efe6;
  --bg-app-tint: #ece5d6;
  --bg-card: #fffcf7;
  --bg-muted: #ebe4d6;
  --bg-inset: #f7f2e8;
  --bg-sidebar: #070b10;
  --bg-sidebar-hover: rgba(240, 160, 48, 0.08);
  --bg-sidebar-active: linear-gradient(135deg, #c48a1a 0%, #9a6b10 100%);
  --grad-primary: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 42%, var(--primary-dark) 100%);
  --grad-sheen: linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 60%);
  --grad-fade: linear-gradient(180deg, var(--bg-card) 0%, color-mix(in srgb, var(--accent) 7%, var(--bg-card)) 100%);

  --text: #1a1610;
  --text-muted: #6b6254;
  --text-faint: #948a79;
  --text-sidebar: #c8d0d8;
  --text-sidebar-muted: #7a8794;

  --border: #e4dccb;
  --border-strong: #d4c9b2;
  --border-accent: color-mix(in srgb, var(--accent) 32%, var(--border));
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 26%, transparent);

  --radius-xs: 6px;
  --radius-sm: 9px;
  --radius: 13px;
  --radius-lg: 17px;
  --radius-xl: 23px;
  --radius-2xl: 30px;

  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-7: 32px; --sp-8: 40px; --sp-9: 56px;

  --fs-xs: 11.5px; --fs-sm: 13px; --fs-base: 14.5px; --fs-md: 16px;
  --fs-lg: 19px; --fs-xl: 23px; --fs-2xl: 29px; --fs-3xl: 38px;

  --shadow-xs: 0 1px 2px rgba(26, 22, 16, 0.04);
  --shadow-sm: 0 2px 10px rgba(26, 22, 16, 0.06);
  --shadow: 0 8px 28px rgba(26, 22, 16, 0.08);
  --shadow-lg: 0 16px 48px rgba(26, 22, 16, 0.14);
  --shadow-xl: 0 28px 72px rgba(26, 22, 16, 0.2);
  --shadow-primary: 0 4px 16px rgba(196, 138, 26, 0.32);
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.6);

  --sidebar-w: 272px;
  --topbar-h: 64px;
  --transition: 0.2s cubic-bezier(0.22, 1, 0.36, 1);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.46, 0.64, 1);
  --dur-fast: 0.14s;
  --dur: 0.26s;
  --dur-slow: 0.5s;
}

body.theme-mess {
  --primary: #0f8a7a;
  --primary-dark: #0b6b5e;
  --primary-light: #2dd4bf;
  --accent: #40e0a0;
  --accent-rgb: 64, 224, 160;
  --on-primary: #f0fffb;
  --bg-app: #eef4f2;
  --bg-app-tint: #e2ece9;
  --bg-card: #f7fffc;
  --bg-muted: #dceae6;
  --bg-inset: #eaf3f0;
  --bg-sidebar: #061210;
  --bg-sidebar-hover: rgba(64, 224, 160, 0.08);
  --bg-sidebar-active: linear-gradient(135deg, #0f8a7a 0%, #0b6b5e 100%);
  --text: #0e1a18;
  --text-muted: #54706a;
  --text-faint: #7c958f;
  --border: #d4e4de;
  --border-strong: #b7d0c8;
  --shadow-primary: 0 4px 16px rgba(15, 138, 122, 0.32);
}

body.theme-battalion {
  --primary: #2b6ea8;
  --primary-dark: #1e5280;
  --primary-light: #5eb0e8;
  --accent: #5eb0e8;
  --accent-rgb: 94, 176, 232;
  --on-primary: #f2faff;
  --bg-app: #eef2f6;
  --bg-app-tint: #e1e8f0;
  --bg-card: #f7fafc;
  --bg-muted: #dde5ee;
  --bg-inset: #eaf0f6;
  --bg-sidebar: #071018;
  --bg-sidebar-hover: rgba(94, 176, 232, 0.08);
  --bg-sidebar-active: linear-gradient(135deg, #2b6ea8 0%, #1e5280 100%);
  --text: #101820;
  --text-muted: #5a6b7a;
  --text-faint: #8395a5;
  --border: #d5dee8;
  --border-strong: #b8c6d4;
  --shadow-primary: 0 4px 16px rgba(43, 110, 168, 0.32);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: auto; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-sidebar);
  color: var(--text);
  display: flex;
  align-items: stretch;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;

  /* Derived tokens re-declared here so each theme's own colours feed them
     (a gradient declared on :root would freeze the canteen values). */
  --grad-primary: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 42%, var(--primary-dark) 100%);
  --grad-fade: linear-gradient(180deg, var(--bg-card) 0%, color-mix(in srgb, var(--accent) 7%, var(--bg-card)) 100%);
  --border-accent: color-mix(in srgb, var(--accent) 32%, var(--border));
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 26%, transparent);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.07);
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.09);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.15);
  --shadow-xl: 0 28px 72px rgba(0, 0, 0, 0.22);
}

::selection {
  background: color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--text);
}

/* ─── Icon system (replaces emoji glyphs) ─── */
.kicon {
  width: 1.25em;
  height: 1.25em;
  flex: 0 0 auto;
  display: inline-block;
  vertical-align: -0.22em;
  stroke: currentColor;
  fill: none;
}

.kicon-img { width: 1.25em; height: 1.25em; object-fit: contain; border-radius: 4px; }

/* Glyph that replaced an inline emoji inside a text run */
.kicon--txt {
  width: 1.15em;
  height: 1.15em;
  vertical-align: -0.24em;
  margin-inline-end: 0.15em;
}
.kicon-text { font-size: 0.95em; line-height: 1; }

.kicon--sm { width: 1em; height: 1em; }
.kicon--md { width: 1.35em; height: 1.35em; }
.kicon--lg { width: 1.75em; height: 1.75em; }
.kicon--xl { width: 2.4em; height: 2.4em; }
.kicon--2x { width: 3.1em; height: 3.1em; }

/* Glyph sits in its own tinted plate inside nav rows and stat cards. */
.kicon-plate {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-inset));
  color: var(--primary-dark);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent);
  font-size: 15px;
}

.kicon-plate--lg { width: 46px; height: 46px; border-radius: 13px; font-size: 20px; }
.kicon-plate--solid {
  background: var(--grad-primary);
  color: var(--on-primary);
  box-shadow: var(--shadow-primary), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

/* ─── Base refinements ─── */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

a { color: var(--primary-dark); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }

.num, .money-num { font-variant-numeric: tabular-nums; }

.eyebrow {
  font-family: var(--font-brand);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.hairline { height: 1px; background: linear-gradient(90deg, transparent, var(--border-strong), transparent); border: 0; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 800;
  white-space: nowrap;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.chip--accent { background: color-mix(in srgb, var(--accent) 15%, var(--bg-card)); border-color: var(--border-accent); color: var(--primary-dark); }
.chip--success { background: var(--success-bg); border-color: color-mix(in srgb, var(--success) 30%, transparent); color: #166534; }
.chip--danger  { background: var(--danger-bg);  border-color: color-mix(in srgb, var(--danger) 30%, transparent);  color: #991b1b; }
.chip--warning { background: var(--warning-bg); border-color: color-mix(in srgb, var(--warning) 32%, transparent); color: #92400e; }
.chip--info    { background: var(--info-bg);    border-color: color-mix(in srgb, var(--info) 30%, transparent);    color: #075985; }

.chip__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 22%, transparent);
  flex: 0 0 auto;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 22%, transparent); }
  50% { box-shadow: 0 0 0 6px color-mix(in srgb, currentColor 6%, transparent); }
}

.chip__dot--live { animation: pulse-dot 2.4s var(--ease) infinite; }

/* ─── Scrollbar ─── */
.sidebar-nav::-webkit-scrollbar,
.data-table-wrap::-webkit-scrollbar { width: 5px; height: 5px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 99px; }
.data-table-wrap::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }

/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--bg-sidebar);
  background-image:
    linear-gradient(rgba(var(--accent-rgb), 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--accent-rgb), 0.035) 1px, transparent 1px),
    radial-gradient(ellipse 120% 70% at 100% 0%, rgba(var(--accent-rgb), 0.14) 0%, transparent 55%),
    radial-gradient(ellipse 80% 50% at 0% 100%, rgba(var(--accent-rgb), 0.07) 0%, transparent 50%);
  background-size: 28px 28px, 28px 28px, auto, auto;
  color: var(--text-sidebar);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  border-left: 1px solid rgba(var(--accent-rgb), 0.12);
  box-shadow: 26px 0 70px -34px rgba(0, 0, 0, 0.62);
  z-index: 200;
  transition: transform var(--transition);
}

.sidebar::before {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 2px;
  background: linear-gradient(180deg, transparent, var(--accent) 22%, var(--primary) 70%, transparent);
  opacity: 0.5;
  z-index: 2;
}

.sidebar::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0, 0, 0, 0.08) 3px,
    rgba(0, 0, 0, 0.08) 4px
  );
  opacity: 0.35;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.sidebar-brand-icon {
  position: relative;
  width: 46px;
  height: 46px;
  clip-path: polygon(9px 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%, 0 9px);
  background: var(--grad-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--on-primary);
  box-shadow: var(--shadow-primary), 0 0 0 1px rgba(var(--accent-rgb), 0.35);
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-brand-icon::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--grad-sheen);
  opacity: 0.5;
  pointer-events: none;
}

.k697-icon-img {
  width: 1.15em;
  height: 1.15em;
  object-fit: contain;
  vertical-align: middle;
}

.sidebar-brand-icon .k697-icon-img,
.login-brand-icon .k697-icon-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.k697-lock-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #0b1016;
  color: #e8eef4;
  font-family: Cairo, Tahoma, sans-serif;
  padding: 24px;
}

.k697-lock-card {
  max-width: 420px;
  text-align: center;
  background: #121a22;
  border: 1px solid #243040;
  border-radius: 16px;
  padding: 36px 28px;
}

.k697-lock-icon { font-size: 42px; margin-bottom: 12px; }
.k697-lock-card h1 { font-size: 22px; margin-bottom: 10px; }
.k697-lock-card p { color: #8a9aaa; font-weight: 600; line-height: 1.7; margin-bottom: 22px; }

.sidebar-header {
  flex-shrink: 0;
  padding: 20px 16px 15px;
  border-bottom: 1px solid rgba(var(--accent-rgb), 0.12);
  position: relative;
  z-index: 1;
}

.sidebar-header h1 {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.sidebar-header .user-sub {
  font-size: 12px;
  color: var(--text-sidebar-muted);
  margin-top: 2px;
}

.sidebar-pill {
  margin-top: 12px;
  padding: 11px 13px;
  border-radius: 13px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(120% 100% at 100% 0%, rgba(255, 255, 255, 0.06), transparent 60%),
    rgba(255, 255, 255, 0.03);
  position: relative;
  overflow: hidden;
}

.sidebar-pill.open {
  border-color: rgba(45, 212, 191, 0.35);
  background:
    radial-gradient(120% 100% at 100% 0%, rgba(45, 212, 191, 0.18), transparent 62%),
    rgba(20, 184, 166, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.sidebar-pill.closed {
  border-color: rgba(248, 113, 113, 0.35);
  background:
    radial-gradient(120% 100% at 100% 0%, rgba(248, 113, 113, 0.16), transparent 62%),
    rgba(185, 28, 28, 0.12);
}

.sidebar-pill .pill-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.85;
}

.sidebar-pill .pill-label .kicon { width: 13px; height: 13px; }

.sidebar-pill .pill-title {
  font-size: 14.5px;
  font-weight: 900;
  color: #f8fafc;
  margin-top: 3px;
}

.sidebar-pill .pill-meta {
  font-size: 11px;
  color: var(--text-sidebar-muted);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

.sidebar-nav {
  flex: 1 1 auto;
  min-height: 0;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  position: relative;
  z-index: 1;
}

.nav-section-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-brand);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--text-sidebar-muted);
  padding: 16px 14px 7px;
  opacity: 0.8;
}

.nav-section-label::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.28), transparent);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 11px;
  color: var(--text-sidebar);
  text-decoration: none;
  font-weight: 700;
  font-size: 13.5px;
  transition: background var(--transition), color var(--transition),
              box-shadow var(--transition), padding-inline-start var(--transition);
  position: relative;
  border: 1px solid transparent;
}

.nav-link:hover {
  background: var(--bg-sidebar-hover);
  color: #fff;
  border-color: rgba(var(--accent-rgb), 0.16);
  padding-inline-start: 15px;
}

.nav-link:hover .nav-icon { color: var(--accent); }

.nav-link.active {
  background:
    linear-gradient(90deg, rgba(var(--accent-rgb), 0.24), rgba(var(--accent-rgb), 0.05) 78%, transparent),
    rgba(255, 255, 255, 0.02);
  color: #fff;
  border-color: rgba(var(--accent-rgb), 0.3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 6px 18px -10px rgba(var(--accent-rgb), 0.9);
}

.nav-link.active::before {
  content: "";
  position: absolute;
  inset-block: 8px;
  inset-inline-start: -10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--grad-primary);
  box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.85);
}

.nav-link.active::after {
  content: "";
  position: absolute;
  inset-inline-end: 11px;
  top: 50%;
  width: 5px;
  height: 5px;
  margin-top: -2.5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.nav-link .nav-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 16px;
  color: var(--text-sidebar-muted);
  background: rgba(255, 255, 255, 0.045);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  transition: color var(--transition), background var(--transition), box-shadow var(--transition);
}

.nav-link .nav-icon .kicon { width: 17px; height: 17px; }

.nav-link.active .nav-icon {
  color: var(--on-primary);
  background: var(--grad-primary);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 4px 12px -4px rgba(var(--accent-rgb), 0.9);
}

.nav-link .nav-label { flex: 1 1 auto; min-width: 0; }

.nav-link .nav-badge {
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(var(--accent-rgb), 0.18);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.3);
}

.sidebar-footer {
  flex-shrink: 0;
  padding: 12px 12px 14px;
  border-top: 1px solid rgba(var(--accent-rgb), 0.12);
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.32));
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  z-index: 1;
}

.sidebar-footer a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: color-mix(in srgb, var(--accent) 70%, #fff);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 700;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.025);
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.sidebar-footer a .kicon { width: 15px; height: 15px; }

.sidebar-footer a:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(var(--accent-rgb), 0.3);
  color: #fff;
}

.sidebar-footer form button,
.btn-close-month {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: white;
  border: none;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transition: filter var(--transition), transform var(--transition), box-shadow var(--transition);
}

.sidebar-footer form button .kicon,
.btn-close-month .kicon { width: 15px; height: 15px; }

.sidebar-footer form button:hover,
.btn-close-month:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(220, 38, 38, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

/* Access-level chip and sidebar action rows (shared shell). */
.sidebar-access { margin-top: 10px; display: flex; }

.badge--solid {
  background: linear-gradient(135deg, color-mix(in srgb, var(--chip-bg, var(--primary)) 84%, #fff) 0%, var(--chip-bg, var(--primary)) 100%);
  color: #fff;
  box-shadow: 0 4px 12px -5px var(--chip-bg, var(--primary)), inset 0 1px 0 rgba(255, 255, 255, 0.28);
  width: auto;
  padding-inline: 12px;
  gap: 7px;
  letter-spacing: 0;
}

.badge--solid::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.18);
}

.sidebar-pill--muted {
  margin-top: 8px;
  border-color: rgba(148, 163, 184, 0.28);
  background: rgba(148, 163, 184, 0.08);
}

.sidebar-pill--muted .pill-label { color: #cbd5e1; }

.sidebar-pill--warning {
  margin-top: 8px;
  border-color: color-mix(in srgb, var(--warning) 38%, transparent);
  background: linear-gradient(160deg, color-mix(in srgb, var(--warning) 16%, transparent), rgba(180, 83, 9, 0.12));
}

.sidebar-pill--warning .pill-label { color: #fcd34d; }

.side-action .kicon,
.hub-owner-console .kicon { width: 15px; height: 15px; }

.side-action--danger {
  color: #fca5a5 !important;
  border-color: rgba(248, 113, 113, 0.24) !important;
}

.side-action--danger:hover {
  background: rgba(185, 28, 28, 0.16) !important;
  border-color: rgba(248, 113, 113, 0.45) !important;
  color: #fee2e2 !important;
}

.topbar-date.is-open { color: #14532d; background: var(--success-bg); border-color: color-mix(in srgb, var(--success) 32%, transparent); }
.topbar-date.is-open .kicon { color: var(--success); }
.topbar-date.is-closed { color: #7f1d1d; background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.topbar-date.is-closed .kicon { color: var(--danger); }

/* ─── Main layout ─── */
.main-wrap {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  background: var(--bg-app);
  background-image:
    radial-gradient(ellipse 70% 42% at 100% 0%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 58%),
    radial-gradient(ellipse 55% 38% at 0% 100%, color-mix(in srgb, var(--primary) 8%, transparent), transparent 60%),
    linear-gradient(180deg, var(--bg-app) 0%, var(--bg-app-tint) 100%);
  background-attachment: fixed;
}

.topbar {
  background: color-mix(in srgb, var(--bg-card) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 10px 30px -22px rgba(26, 22, 16, 0.5);
}

.topbar::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.55;
}

.topbar-menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--bg-card);
  cursor: pointer;
  font-size: 20px;
  color: var(--text);
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}

.topbar-menu-btn:hover {
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-card));
  border-color: var(--border-accent);
}

.topbar-menu-btn:active { transform: scale(0.94); }

.topbar-search {
  flex: 1 1 260px;
  position: relative;
  max-width: 420px;
}

.topbar-search input {
  width: 100%;
  padding: 10px 42px 10px 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  font-family: inherit;
  font-size: 14px;
  background: var(--bg-inset);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.topbar-search input::placeholder { color: var(--text-faint); }

.topbar-search input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--bg-card);
  box-shadow: var(--ring);
}

.topbar-search::before {
  content: "";
  position: absolute;
  inset-inline-start: 15px;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  pointer-events: none;
  opacity: 0.5;
  background: currentColor;
  -webkit-mask: no-repeat center / contain
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.9' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='M15.8 15.8L21 21'/%3E%3C/svg%3E");
  mask: no-repeat center / contain
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.9' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='M15.8 15.8L21 21'/%3E%3C/svg%3E");
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-right: auto;
}

.topbar-date {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 12.5px;
  color: var(--text-muted);
  background: var(--bg-inset);
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.topbar-date .kicon { width: 14px; height: 14px; color: var(--primary); }

.topbar-user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 13px 5px 6px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

.topbar-user-chip .avatar {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--grad-primary);
  color: var(--on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  font-weight: 900;
  box-shadow: var(--shadow-primary), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.topbar-user-chip .avatar::after {
  content: "";
  position: absolute;
  inset-block-end: -1px;
  inset-inline-end: -1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 2px var(--bg-inset);
}

.content {
  flex: 1 1 auto;
  padding: 30px 34px 44px;
  animation: fadeIn 0.35s var(--ease);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Motion layer (added by k697-ui.js, never without JS) ─── */
.k697-motion .k697-reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity var(--dur-slow) var(--ease) var(--k697-delay, 0ms),
              transform var(--dur-slow) var(--ease-spring) var(--k697-delay, 0ms);
}

.k697-motion .k697-reveal.is-in {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .k697-motion .k697-reveal { opacity: 1; transform: none; transition: none; }
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

.site-footer {
  margin-top: auto;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-faint);
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--bg-card) 78%, transparent));
  border-top: 1px solid var(--border);
  font-family: var(--font-brand);
  letter-spacing: 0.08em;
}

.site-footer__mark {
  display: inline-flex;
  align-items: center;
  color: var(--accent);
  opacity: .75;
}

.site-footer__mark .kicon { width: 14px; height: 14px; }

.site-footer__sep {
  width: 22px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-accent), transparent);
}

.site-footer__year {
  color: color-mix(in srgb, var(--text-faint) 80%, transparent);
  font-variant-numeric: tabular-nums;
}

/* ─── Page header ─── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 26px;
  padding: 18px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 55%),
    var(--grad-fade);
  box-shadow: var(--shadow-sm), var(--shadow-inset);
  position: relative;
  overflow: hidden;
}

.page-header::before {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 4px;
  background: var(--grad-primary);
  box-shadow: 0 0 22px rgba(var(--accent-rgb), 0.5);
}

.page-header::after {
  content: "";
  position: absolute;
  inset-block-start: 0;
  inset-inline-end: 0;
  width: 120px;
  height: 120px;
  background:
    linear-gradient(rgba(var(--accent-rgb), 0.09) 1px, transparent 1px) 0 0 / 14px 14px,
    linear-gradient(90deg, rgba(var(--accent-rgb), 0.09) 1px, transparent 1px) 0 0 / 14px 14px;
  -webkit-mask: linear-gradient(225deg, #000, transparent 70%);
  mask: linear-gradient(225deg, #000, transparent 70%);
  pointer-events: none;
}

.page-header > * { position: relative; z-index: 1; }

.page-title {
  font-size: var(--fs-2xl);
  font-weight: 900;
  color: var(--text);
  letter-spacing: -0.025em;
  line-height: 1.22;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.page-subtitle {
  font-size: var(--fs-base);
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 6px;
}

.page-header__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.content > .page-title:not(.page-header .page-title) {
  margin-bottom: 20px;
}

/* ─── Stats grid ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.stat-card {
  border-radius: var(--radius-lg);
  padding: 20px 20px 18px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--stat-accent, var(--primary)), color-mix(in srgb, var(--stat-accent, var(--primary)) 25%, transparent));
}

.stat-card::after {
  content: "";
  position: absolute;
  inset-block-start: -34px;
  inset-inline-end: -34px;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--stat-accent, var(--accent)) 22%, transparent), transparent 68%);
  opacity: 0.55;
  pointer-events: none;
  transition: opacity var(--transition);
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--border-accent);
}

.stat-card:hover::after { opacity: 0.9; }

.stat-card > * { position: relative; z-index: 1; }

.stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-size: 17px;
  color: var(--stat-accent, var(--primary-dark));
  background: color-mix(in srgb, var(--stat-accent, var(--accent)) 15%, var(--bg-card));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--stat-accent, var(--accent)) 28%, transparent);
}

.stat-icon .kicon { width: 18px; height: 18px; }

.stat-label {
  font-size: var(--fs-sm);
  font-weight: 800;
  color: var(--text-muted);
  line-height: 1.4;
  letter-spacing: -0.005em;
}

.stat-value {
  font-size: var(--fs-2xl);
  font-weight: 900;
  line-height: 1.12;
  color: var(--text);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.stat-foot {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-weight: 700;
  line-height: 1.7;
}

.stat-green { --stat-accent: var(--success); background: linear-gradient(160deg, var(--bg-card) 0%, var(--success-bg) 100%); }
.stat-green .stat-value { color: #15803d; }
.stat-blue  { --stat-accent: var(--primary); background: linear-gradient(160deg, var(--bg-card) 0%, color-mix(in srgb, var(--accent) 10%, var(--bg-card)) 100%); }
.stat-blue  .stat-value { color: var(--primary-dark); }
.stat-yellow{ --stat-accent: var(--warning); background: linear-gradient(160deg, var(--bg-card) 0%, var(--warning-bg) 100%); }
.stat-yellow .stat-value { color: #b45309; }
.stat-purple{ --stat-accent: #7c3aed; background: linear-gradient(160deg, var(--bg-card) 0%, #f5f3ff 100%); }
.stat-purple .stat-value { color: #6d28d9; }
.stat-pink  { --stat-accent: #db2777; background: linear-gradient(160deg, var(--bg-card) 0%, #fdf2f8 100%); }
.stat-pink  .stat-value { color: #be185d; }
.stat-red {
  --stat-accent: #dc2626;
  background: linear-gradient(160deg, var(--bg-card) 0%, #fef2f2 100%);
}
.stat-red .stat-value { color: #b91c1c; }
.stat-cyan {
  --stat-accent: #0ea5e9;
  background: linear-gradient(160deg, var(--bg-card) 0%, #f0f9ff 100%);
}
.stat-cyan .stat-value { color: #0369a1; }

.stat-card.featured {
  border-width: 2px;
  border-color: var(--stat-border, var(--border));
}

.stat-card.featured-gold {
  --stat-accent: #d97706;
  --stat-border: #fbbf24;
  background: linear-gradient(145deg, #fffbeb 0%, #fef3c7 100%);
}
.stat-card.featured-gold .stat-label { color: #92400e; }
.stat-card.featured-gold .stat-value { color: #78350f; }

.stat-card.featured-green {
  --stat-accent: #16a34a;
  --stat-border: #4ade80;
  background: linear-gradient(145deg, #ecfdf5 0%, #d1fae5 100%);
}
.stat-card.featured-green .stat-label { color: #166534; }
.stat-card.featured-green .stat-value { color: #15803d; }

.stat-card.featured-red {
  --stat-accent: #dc2626;
  --stat-border: #f87171;
  background: linear-gradient(145deg, #fef2f2 0%, #fee2e2 100%);
}
.stat-card.featured-red .stat-label { color: #991b1b; }
.stat-card.featured-red .stat-value { color: #b91c1c; }

.stat-card.featured-orange {
  --stat-accent: #ea580c;
  --stat-border: #fb923c;
  background: linear-gradient(145deg, #fff7ed 0%, #fed7aa 100%);
}
.stat-card.featured-orange .stat-label { color: #9a3412; }
.stat-card.featured-orange .stat-value { color: #7c2d12; }

.stat-card.featured-sky {
  --stat-accent: #0284c7;
  --stat-border: #38bdf8;
  background: linear-gradient(145deg, #f0f9ff 0%, #bae6fd 100%);
}
.stat-card.featured-sky .stat-label { color: #075985; }
.stat-card.featured-sky .stat-value { color: #0c4a6e; }

.stat-card.featured-army {
  --stat-accent: var(--primary);
  --stat-border: var(--primary-light);
  background: linear-gradient(145deg, var(--bg-card) 0%, color-mix(in srgb, var(--accent) 16%, var(--bg-card)) 100%);
}
.stat-card.featured-army .stat-label { color: var(--primary-dark); }
.stat-card.featured-army .stat-value { color: var(--primary-dark); }

/* ─── Cards ─── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm), var(--shadow-inset);
  transition: box-shadow var(--transition), border-color var(--transition);
  position: relative;
}

.card:hover {
  box-shadow: var(--shadow);
  border-color: var(--border-accent);
}

.card + .card { margin-top: 16px; }

.card h2 {
  font-size: var(--fs-md);
  font-weight: 800;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.015em;
}

.card h2 > .kicon { color: var(--primary); width: 19px; height: 19px; }

.card h3 {
  font-size: var(--fs-base);
  font-weight: 800;
  color: var(--text);
  margin: 14px 0 10px;
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.card-header-row h2 { margin-bottom: 0; }

.card--flush { padding: 0; overflow: hidden; }
.card--flush .card-header-row { padding: 18px 22px 0; margin-bottom: 14px; }
.card--flush .data-table-wrap { border: 0; border-radius: 0; border-top: 1px solid var(--border); }

.card__note {
  font-size: var(--fs-xs);
  color: var(--text-faint);
  font-weight: 700;
  margin-top: -8px;
  margin-bottom: 14px;
}

.month-status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 4px 0;
}

/* ─── Tables ── */
.data-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

table.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-base);
}

table.data-table th,
table.data-table td {
  padding: 13px 15px;
  text-align: center;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

table.data-table th {
  background: linear-gradient(180deg, var(--bg-muted), color-mix(in srgb, var(--bg-muted) 78%, var(--bg-card)));
  color: var(--text);
  font-weight: 800;
  font-size: var(--fs-sm);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
  letter-spacing: -0.01em;
  box-shadow: inset 0 -2px 0 var(--primary);
}

table.data-table th .kicon { width: 14px; height: 14px; opacity: 0.65; vertical-align: -2px; }

table.data-table tbody tr { transition: background var(--transition), box-shadow var(--transition); }

table.data-table tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--bg-muted) 40%, var(--bg-card));
}

table.data-table tbody tr:hover td {
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-card));
}

table.data-table tbody tr:hover td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

table.data-table tbody tr:last-child td { border-bottom: none; }

table.data-table tfoot td {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 10%, var(--bg-muted)), var(--bg-muted));
  font-weight: 900;
  border-bottom: none;
  border-top: 2px solid var(--border-strong);
  font-variant-numeric: tabular-nums;
}

tfoot .label-col { text-align: right; font-weight: 800; }

/* ─── Forms ─── */
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.col { flex: 1 1 220px; min-width: 160px; }

label.field,
.field > label,
.field-label {
  display: block;
  font-weight: 800;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-bottom: 7px;
  letter-spacing: -0.005em;
}

label.field .req { color: var(--danger); }

input.field,
select.field,
textarea.field {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  font-family: inherit;
  font-size: var(--fs-base);
  color: var(--text);
  background: var(--bg-card);
  box-shadow: inset 0 1px 2px rgba(26, 22, 16, 0.05);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

input.field::placeholder,
textarea.field::placeholder { color: var(--text-faint); }

input.field:hover:not(:focus),
select.field:hover:not(:focus),
textarea.field:hover:not(:focus) { border-color: var(--border-accent); }

input.field:focus,
select.field:focus,
textarea.field:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
  background: var(--bg-card);
}

input.field:disabled,
select.field:disabled,
textarea.field:disabled {
  background: var(--bg-inset);
  color: var(--text-faint);
  cursor: not-allowed;
  opacity: 1;
}

select.field {
  appearance: none;
  -webkit-appearance: none;
  padding-inline-end: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6254' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 9l7 7 7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 13px center;
  background-size: 15px;
}

textarea.field { min-height: 92px; resize: vertical; line-height: 1.7; }
input.field.sm, select.field.sm { padding: 7px 11px; font-size: var(--fs-sm); border-radius: 9px; }
input.field.lg, select.field.lg { padding: 14px 16px; font-size: var(--fs-md); }

input[type="checkbox"].field,
input[type="radio"].field {
  width: 18px;
  height: 18px;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-card);
  cursor: pointer;
  display: inline-grid;
  place-content: center;
  transition: background var(--transition), border-color var(--transition);
}

input[type="checkbox"].field { border-radius: 6px; }
input[type="radio"].field { border-radius: 50%; }

input[type="checkbox"].field:checked,
input[type="radio"].field:checked {
  background: var(--grad-primary);
  border-color: var(--primary-dark);
}

input[type="checkbox"].field:checked::after {
  content: "";
  width: 11px;
  height: 11px;
  background: no-repeat center / contain
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 12.5l5 5 10-11'/%3E%3C/svg%3E");
}

input[type="radio"].field:checked::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--on-primary);
}

input[type="color"].field {
  padding: 4px;
  height: 42px;
  width: 64px;
  cursor: pointer;
  border-radius: 11px;
}

.field-hint {
  display: block;
  font-size: var(--fs-xs);
  color: var(--text-faint);
  font-weight: 700;
  margin-top: 6px;
}

/* ─── Buttons ─── */
.btn {
  position: relative;
  padding: 10px 18px;
  border: none;
  border-radius: 11px;
  font-weight: 800;
  font-size: var(--fs-sm);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: inherit;
  transition: filter var(--transition), transform var(--transition),
              box-shadow var(--transition), background var(--transition), color var(--transition);
  white-space: nowrap;
  line-height: 1.35;
  letter-spacing: -0.005em;
  box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.btn .kicon { width: 15px; height: 15px; flex: 0 0 auto; }

.btn:hover {
  filter: brightness(1.05);
  transform: translateY(-1.5px);
}

.btn:active { transform: translateY(0) scale(0.985); }

.btn-primary {
  background: var(--grad-primary);
  color: var(--on-primary);
  box-shadow: var(--shadow-primary), inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.btn-success {
  background: linear-gradient(135deg, #22c55e 0%, #15803d 100%);
  color: #f0fdf4;
  box-shadow: 0 4px 14px rgba(22, 163, 74, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  color: #fff5f5;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-warning {
  background: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
  color: #451a03;
  box-shadow: 0 4px 14px rgba(217, 119, 6, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.btn-muted {
  background: linear-gradient(135deg, #94a3b8, #64748b);
  color: #fff;
  box-shadow: 0 4px 12px rgba(100, 116, 139, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-info {
  background: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
  color: #f0f9ff;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.btn-outline {
  background: var(--bg-card);
  border: 1.5px solid var(--border-strong);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-card));
  filter: none;
}

.btn-ghost {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  box-shadow: none;
}

.btn-ghost:hover {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--primary-dark);
  filter: none;
}

.btn-sm { padding: 6px 12px; font-size: var(--fs-xs); border-radius: 9px; }
.btn-sm .kicon { width: 13px; height: 13px; }
.btn-lg { padding: 13px 24px; font-size: var(--fs-base); border-radius: var(--radius); }
.btn-lg .kicon { width: 18px; height: 18px; }

.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: 10px; }
.btn-icon .kicon { width: 16px; height: 16px; }

/* Compact action cluster used inside table rows. */
.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px;
  border-radius: 10px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
}

.row-actions .btn { border-radius: 7px; box-shadow: none; padding: 5px 9px; }
.row-actions .btn:hover { transform: none; }

.actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}

/* ─── Alerts ── */
.alert {
  position: relative;
  overflow: hidden;
  padding: 13px 18px 13px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-weight: 700;
  font-size: var(--fs-base);
  /* block مش flex: النص فيه <strong> و<a> جوه الفقرة، والـflex كان بيقسّمهم أعمدة ضيقة */
  display: block;
  line-height: 1.65;
  border: 1px solid transparent;
  box-shadow: var(--shadow-xs);
}

.alert::before {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 4px;
  background: currentColor;
  opacity: 0.75;
}

.alert .kicon { width: 16px; height: 16px; vertical-align: -3px; margin-inline-end: 4px; }

.alert-success { background: linear-gradient(100deg, #dcfce7, #f0fdf4); color: #14532d; border-color: #bbf7d0; }
.alert-danger  { background: linear-gradient(100deg, #fee2e2, #fef2f2); color: #7f1d1d; border-color: #fecaca; }
.alert-info    { background: linear-gradient(100deg, color-mix(in srgb, var(--accent) 16%, #fff), color-mix(in srgb, var(--accent) 5%, #fff)); color: var(--primary-dark); border-color: color-mix(in srgb, var(--accent) 38%, #fff); }
.alert-warning { background: linear-gradient(100deg, #fef3c7, #fffbeb); color: #78350f; border-color: #fde68a; }

/* ─── Tabs ─── */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  background: linear-gradient(180deg, var(--bg-muted), color-mix(in srgb, var(--bg-muted) 80%, var(--bg-card)));
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: inset 0 1px 3px rgba(26, 22, 16, 0.06);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 17px;
  font-weight: 800;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: 10px;
  font-size: var(--fs-base);
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
  border: none;
  background: transparent;
  font-family: inherit;
}

.tab .kicon { width: 15px; height: 15px; opacity: 0.8; }

.tab:hover { color: var(--text); background: color-mix(in srgb, var(--bg-card) 72%, transparent); }

.tab.active {
  color: var(--primary-dark);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--border-accent);
}

.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fadeIn 0.25s ease; }

/* ─── Badges ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 800;
  line-height: 1.4;
  letter-spacing: 0.01em;
  box-shadow: inset 0 0 0 1px currentColor;
}

.badge .kicon { width: 13px; height: 13px; }

.badge-open   { background: #dcfce7; color: #15803d; }
.badge-closed { background: #fee2e2; color: #b91c1c; }
.badge-active { background: color-mix(in srgb, var(--accent) 18%, #fff); color: var(--primary-dark); }

/* ─── Toolbar ─── */
.toolbar {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  padding: 14px 16px;
  flex-wrap: wrap;
  background: linear-gradient(180deg, var(--bg-card), color-mix(in srgb, var(--accent) 5%, var(--bg-card)));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.toolbar .toolbar-left,
.toolbar .toolbar-right {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.invoice-header-info {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.invoice-header-info .inv-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.invoice-header-info .inv-title h2 { margin: 0; }

.invoice-header-info .inv-meta {
  display: flex;
  gap: 14px;
  font-size: 14px;
  font-weight: 700;
  flex-wrap: wrap;
}

/* ─── Deficit card ─── */
.deficit-card {
  background: linear-gradient(135deg, #fff5f5 0%, #fee2e2 100%);
  border: 2px solid #ef4444;
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: 0 4px 18px rgba(220, 38, 38, 0.15);
}

.deficit-card .stat-label { color: #991b1b; font-size: 15px; font-weight: 800; }

.deficit-card .stat-value {
  color: #7f1d1d;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.deficit-card.negative {
  background: linear-gradient(135deg, #fef2f2 0%, #fecaca 100%);
  border-color: #dc2626;
}

.deficit-card.negative .stat-value { color: #450a0a; }

.deficit-card.positive {
  background: linear-gradient(135deg, #ecfdf5 0%, #bbf7d0 100%);
  border-color: #16a34a;
  box-shadow: 0 4px 18px rgba(22, 163, 74, 0.15);
}

.deficit-card.positive .stat-label { color: #166534; }
.deficit-card.positive .stat-value { color: #14532d; }

.deficit-card.even {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border-color: #2563eb;
  box-shadow: 0 4px 18px rgba(37, 99, 235, 0.15);
}

.deficit-card.even .stat-label { color: #1e40af; }
.deficit-card.even .stat-value { color: #1d4ed8; }

.money-num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: 0.01em;
}

/* ─── Mess calendar ─── */
.day-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
}

.day-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 6px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  min-height: 64px;
  transition: all var(--transition);
}

.day-cell:hover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-card));
}

.day-cell.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary-dark);
  box-shadow: var(--shadow-primary);
}

.day-cell .dow {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.75;
}

.chk-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}

.chk-row input[type=checkbox] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

/* ─── Sidebar overlay ─── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(7, 11, 16, 0.58);
  z-index: 199;
  backdrop-filter: blur(3px);
}

body.sidebar-open .sidebar-overlay { display: block; }

/* ─── Login ─── */
body.login-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(ellipse 70% 45% at 50% -5%, rgba(var(--accent-rgb), 0.18), transparent 55%),
    linear-gradient(180deg, #020406 0%, #0a1218 45%, #040608 100%);
  position: relative;
}

body.login-page::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(var(--accent-rgb), 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--accent-rgb), 0.05) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 45%, #000 10%, transparent 75%);
}

body.login-page::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0, 0, 0, 0.12) 3px,
    rgba(0, 0, 0, 0.12) 4px
  );
  opacity: 0.45;
}

.login-k697 {
  font-family: var(--font-brand);
  font-size: 0.72rem;
  letter-spacing: 0.42em;
  color: color-mix(in srgb, var(--accent) 70%, #fff);
  text-align: center;
  margin-bottom: 10px;
  direction: ltr;
}

.login-card {
  background: rgba(8, 12, 16, 0.88);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(var(--accent-rgb), 0.08);
  width: 100%;
  max-width: 440px;
  padding: 40px 36px;
  animation: fadeIn 0.5s var(--ease);
  position: relative;
  z-index: 1;
  color: #d8e0e8;
}

.login-card > form { display: grid; gap: 4px; }

.login-field { display: block; margin-top: 14px; }

.login-field__wrap { position: relative; display: block; }

.login-field__ico {
  position: absolute;
  inset-inline-end: 14px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  color: var(--accent);
  opacity: .65;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}

.login-field__ico .kicon { width: 17px; height: 17px; }

.login-field__wrap:focus-within .login-field__ico { opacity: 1; }

.login-field input.field { padding-inline-end: 42px; }

.login-submit {
  width: 100%;
  margin-top: 22px;
  justify-content: center;
  gap: 10px;
}

.login-submit .kicon { width: 18px; height: 18px; }

.login-submit:hover .kicon { transform: translateX(-3px); }

.login-submit .kicon { transition: transform var(--dur) var(--ease-spring); }

.login-card::before,
.login-card::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: var(--accent);
  border-style: solid;
  opacity: 0.7;
}

.login-card::before {
  top: 10px;
  right: 10px;
  border-width: 2px 2px 0 0;
}

.login-card::after {
  bottom: 10px;
  left: 10px;
  border-width: 0 0 2px 2px;
}

.login-brand { text-align: center; margin-bottom: 28px; }

.login-brand-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
  background: var(--bg-sidebar-active);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  box-shadow: var(--shadow-primary);
}

.login-brand h1 {
  font-size: 24px;
  font-weight: 900;
  color: #f4f0e8;
  margin-bottom: 6px;
}

.login-brand p {
  color: rgba(200, 210, 220, 0.65);
  font-size: 14px;
  font-weight: 600;
}

body.login-page .alert-info {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: color-mix(in srgb, var(--accent) 80%, #fff);
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
}

body.login-page label.field { color: #c8d4dc; }

body.login-page input.field {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
  color: #f0f4f8;
}

body.login-page input.field::placeholder { color: rgba(180, 195, 205, 0.4); }

body.login-page input.field:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.06);
}

.login-footer {
  margin-top: 24px;
  color: rgba(var(--accent-rgb), 0.45);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  position: relative;
  z-index: 1;
  font-family: var(--font-brand);
  letter-spacing: 0.12em;
}

.login-hint {
  text-align: center;
  margin-top: 20px;
  color: rgba(180, 195, 205, 0.7);
  font-size: 13px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius);
  padding: 14px;
  border: 1px dashed color-mix(in srgb, var(--accent) 22%, transparent);
}

.login-hint b { color: #f0f4f8; }

body.login-page .hub-login-link {
  color: rgba(200, 210, 220, 0.7);
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed color-mix(in srgb, var(--accent) 28%, transparent);
}

body.login-page .hub-login-link:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

/* ─── Dashboard bento ─── */
.dash { --dash-radius: 18px; }

.dash-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.dash-top h1 {
  font-size: clamp(26px, 3.5vw, 32px);
  font-weight: 900;
  letter-spacing: -0.03em;
  color: var(--text);
  margin: 0 0 4px;
  line-height: 1.15;
}

.dash-top .sub {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 600;
}

.dash-top-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.dash-month-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

.dash-month-chip.is-open { border-color: #a7f3d0; background: #f0fdf4; color: #166534; }
.dash-month-chip.is-closed { border-color: #fecaca; background: #fef2f2; color: #991b1b; }

.dash-bento {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.dash-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--dash-radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition), transform var(--transition);
}

.dash-tile:hover { box-shadow: var(--shadow-sm); }

.dash-tile .tile-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.dash-tile .tile-value {
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.dash-tile .tile-value .unit {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  margin-right: 2px;
}

.dash-tile .tile-note {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.75;
}

.dash-tile--hero {
  grid-column: span 7;
  background: linear-gradient(145deg, var(--bg-card) 0%, color-mix(in srgb, var(--accent) 8%, var(--bg-card)) 100%);
  position: relative;
  overflow: hidden;
}

.dash-tile--hero::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 5px;
  height: 100%;
  background: linear-gradient(180deg, var(--accent), var(--primary-dark));
  border-radius: 0 var(--dash-radius) var(--dash-radius) 0;
}

.dash-tile--hero .tile-value { color: var(--primary-dark); }

.dash-tile--profit {
  grid-column: span 5;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 148px;
}

.dash-tile--profit.is-up { background: linear-gradient(160deg, var(--bg-card) 0%, #f0fdf4 100%); border-color: #bbf7d0; }
.dash-tile--profit.is-up .tile-value { color: #15803d; }
.dash-tile--profit.is-down { background: linear-gradient(160deg, var(--bg-card) 0%, #fef2f2 100%); border-color: #fecaca; }
.dash-tile--profit.is-down .tile-value { color: #b91c1c; }

.dash-tile--sm { grid-column: span 3; min-height: 118px; }
.dash-tile--sm .tile-value { font-size: clamp(18px, 2.2vw, 22px); }
.dash-tile--sm.is-add .tile-value { color: #15803d; }
.dash-tile--sm.is-sub .tile-value { color: #b91c1c; }
.dash-tile--sm.is-warn .tile-value { color: #b45309; }
.dash-tile--sm.is-info .tile-value { color: var(--primary-dark); }

.dash-tile--nav { grid-column: span 12; padding: 14px 16px; }

.dash-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.dash-nav a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 12px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  background: var(--bg-muted);
  border: 1px solid transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.dash-nav a:hover {
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-card));
  color: var(--primary-dark);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}

.dash-nav a .ico { font-size: 16px; line-height: 1; }

.dash-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.dash-metric {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  text-align: center;
}

.dash-metric .m-lbl {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
  line-height: 1.35;
}

.dash-metric .m-val {
  font-size: 17px;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -0.02em;
}

.dash-metric .m-val small {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.dash-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.dash-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--dash-radius);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.dash-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-muted);
}

.dash-panel-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
}

.dash-feed { list-style: none; margin: 0; padding: 0; }

.dash-feed-item {
  display: grid;
  grid-template-columns: 88px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.dash-feed-item:last-child { border-bottom: none; }
.dash-feed-item:hover { background: var(--bg-muted); }

.dash-feed-item .feed-date {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.dash-feed-item .feed-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-feed-item .feed-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 2px;
}

.dash-feed-item .feed-amt {
  text-align: left;
  font-size: 14px;
  font-weight: 900;
  color: var(--primary-dark);
  white-space: nowrap;
}

.dash-feed-item .feed-amt.is-profit { color: #16a34a; }
.dash-feed-item .feed-amt.is-loss { color: #dc2626; }

.dash-feed-empty {
  padding: 36px 20px;
  text-align: center;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 14px;
}

.dash-feed-empty a { color: var(--primary); font-weight: 800; }

.type-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 800;
  vertical-align: middle;
}

.type-pill.purchase { background: #fee2e2; color: #991b1b; }
.type-pill.sale { background: #dcfce7; color: #166534; }
.type-pill.cash { background: color-mix(in srgb, var(--accent) 18%, #fff); color: var(--primary-dark); }

/* ─── Print ─── */
@page { size: A4; margin: 12mm 10mm; }

@media print {
  /* A reveal caught mid-transition prints as a ghosted panel, so kill motion first. */
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }

  .sidebar, .topbar, .no-print, nav, .btn, form, .site-footer, .sidebar-overlay,
  .phone-nav, .install-banner, .k697-install-card, .app-install-help, .hub-nav-top,
  .table-tools, .k697-export, .row-actions, .toolbar, .tabs, .dash-nav { display: none !important; }

  html, body {
    display: block;
    background: #fff !important;
    color: #000 !important;
    font-size: 12px;
  }

  .main-wrap { width: 100%; background: #fff !important; background-image: none !important; }
  .content { padding: 0; animation: none; background: #fff !important; }

  .page-header {
    background: #fff !important;
    border: none;
    border-bottom: 2px solid #000;
    border-radius: 0;
    box-shadow: none;
    padding: 0 0 8px;
    margin-bottom: 14px;
  }

  .page-header::before, .page-header::after { display: none; }
  .page-title, .page-subtitle { color: #000 !important; font-size: 18px; }

  /* Printed slip identity: portal + month + date, without touching the markup */
  .content::before {
    content: attr(data-print-title);
    display: block;
    font-weight: 800;
    font-size: 11px;
    color: #444;
    margin-bottom: 4px;
  }

  .card, .stat-card {
    background: #fff !important;
    border: 1px solid #bbb !important;
    border-radius: 4px;
    box-shadow: none !important;
    padding: 10px 12px;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .card::before, .stat-card::after, .stat-card::before { display: none !important; }
  .card h2, .stat-label, .stat-value, .stat-mini { color: #000 !important; }
  .deficit-card {
    background: #fff !important;
    border: 1px solid #999 !important;
    box-shadow: none !important;
  }
  .stats-grid { display: block; }
  .stats-grid > * { display: inline-block; width: 24%; vertical-align: top; }

  .data-table-wrap { overflow: visible !important; border: none !important; }
  table.data-table { min-width: 0 !important; width: 100%; border-collapse: collapse; font-size: 10px; }
  table.data-table thead { display: table-header-group; }
  table.data-table tr { break-inside: avoid; page-break-inside: avoid; }
  table.data-table th, table.data-table td {
    border: 1px solid #666 !important;
    background: #fff !important;
    color: #000 !important;
    box-shadow: none !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    padding: 4px 5px;
  }
  table.data-table th {
    background: #efefef !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    font-weight: 800;
  }
  table.data-table tfoot tr { border-top: 2px solid #000; font-weight: 800; }
  table.data-table td:first-child::after { display: none !important; }

  .kicon { stroke-width: 1.4; width: 12px; height: 12px; }
  .k697-motion .k697-reveal { opacity: 1 !important; transform: none !important; }
  a { text-decoration: none; color: #000; }
}

/* ─── Responsive ─── */
@media (max-width: 1100px) {
  .dash-tile--hero, .dash-tile--profit { grid-column: span 12; }
  .dash-tile--sm { grid-column: span 6; }
  .dash-metrics { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
  .topbar-menu-btn { display: flex; }
  body { flex-direction: row; background: var(--bg-app); }

  .sidebar {
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    width: min(var(--sidebar-w), 86vw);
    transform: translateX(100%);
    box-shadow: var(--shadow-lg);
  }

  body.sidebar-open .sidebar { transform: translateX(0); }

  /* The drawer is only ~86% of the screen — the fixed blocks above the menu
     must stay small enough that the nav items and pinned actions are both visible. */
  .sidebar-header { padding: 12px 12px 10px; }
  .sidebar-brand { gap: 9px; margin-bottom: 9px; }
  .sidebar-brand-icon { width: 32px; height: 34px; font-size: 17px; clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px); }
  .sidebar-header h1 { font-size: 14px; }
  .sidebar-header .user-sub { font-size: 11px; }
  .sidebar-access { margin-top: 8px; }
  .sidebar-access .badge--solid { font-size: 10.5px; padding: 3px 9px; }

  .sidebar-pill {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 8px;
    margin-top: 8px;
    padding: 7px 10px;
    border-radius: 10px;
  }
  .sidebar-pill .pill-label { flex: 1 1 100%; gap: 5px; font-size: 9px; }
  .sidebar-pill .pill-label .kicon { width: 11px; height: 11px; }
  .sidebar-pill .pill-title { margin-top: 0; font-size: 12.5px; }
  .sidebar-pill .pill-meta { margin-top: 0; margin-inline-start: auto; font-size: 10px; }

  .sidebar-nav { padding: 8px 8px 10px; }
  .nav-section-label { padding: 8px 10px 4px; font-size: 8px; letter-spacing: 0.12em; }
  .nav-link { gap: 9px; padding: 7px 10px; font-size: 12.5px; }
  .nav-link:hover { padding-inline-start: 10px; }
  .nav-link .nav-icon { width: 26px; height: 26px; border-radius: 8px; font-size: 14px; }
  .nav-link .nav-icon .kicon { width: 15px; height: 15px; }
  .nav-link .nav-badge { font-size: 9.5px; padding: 1px 6px; }

  .sidebar-footer { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); gap: 5px; }
  .sidebar-footer a { padding: 8px 9px; font-size: 12px; }
  .sidebar-footer form button,
  .btn-close-month { padding: 8px 12px; font-size: 12.5px; }

  .main-wrap { width: 100%; }
  .content { padding: 20px 16px 32px; }
  .page-title { font-size: 22px; }
}

@media (max-width: 768px) {
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar-search { flex-basis: 100%; max-width: none; order: 3; }
  .topbar-meta { margin-right: 0; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stat-value { font-size: 22px; }
  .card { padding: 18px 16px; }
  table.data-table { min-width: 640px; font-size: 13px; }
  table.data-table th,
  table.data-table td { padding: 10px 10px; }
}

@media (max-width: 720px) {
  .dash-tile--sm { grid-column: span 12; }
  .dash-metrics { grid-template-columns: repeat(2, 1fr); }
  .dash-panels { grid-template-columns: 1fr; }
  .dash-feed-item { grid-template-columns: 1fr; gap: 4px; }
  .dash-feed-item .feed-amt { text-align: right; }
  .dash-nav { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .dash-nav a { white-space: nowrap; flex-shrink: 0; }
}

@media (max-width: 520px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-value { font-size: 20px; }
  .page-title { font-size: 20px; }
  .btn { padding: 9px 14px; font-size: 13px; }
  .row { gap: 10px; }
  .col { flex: 1 1 100%; min-width: 100%; }
}

@media (max-width: 480px) {
  .login-card { padding: 28px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ═══════════════════════════════════════════════════════════
   Polish pack — status strips, trends, calendar, table tools
   ═══════════════════════════════════════════════════════════ */

/* ─── Equal-height KPI cards ─── */
.stats-grid { align-items: stretch; }

.stat-card { min-height: 118px; }

.stat-card .stat-foot { margin-top: auto; }

.stat-card .stat-value,
.stat-card .stat-label {
  overflow-wrap: anywhere;
}

.money-num {
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
}

/* داخل الجداول الخلية لازم تفضل table-cell وإلا الجدول كله يختل */
td.money-num,
th.money-num {
  display: table-cell;
}

/* ─── Compact status strip (replaces large empty notice cards) ─── */
.status-strip {
  display: flex;
  align-items: center;
  gap: 10px 14px;
  flex-wrap: wrap;
  padding: 10px 16px;
  margin-bottom: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.status-strip .ss-month {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
}

.status-strip .ss-range {
  color: var(--text-muted);
  font-weight: 700;
  font-size: 12.5px;
}

.status-strip .ss-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
}

.status-strip .ss-hint {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12.5px;
}

.status-strip .ss-actions {
  margin-inline-start: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ─── Month trend bars ─── */
.trend { margin-top: 6px; }

.trend-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.trend-cap {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-muted);
}

.trend-delta {
  font-size: 12px;
  font-weight: 800;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
}

.trend-delta small { font-size: 10.5px; font-weight: 600; opacity: .8; }
.trend-delta.up   { color: #15803d; background: #ecfdf5; }
.trend-delta.down { color: #b91c1c; background: #fef2f2; }

.trend-bars {
  display: flex;
  align-items: stretch;
  gap: 8px;
  height: 108px;
}

.trend-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
}

.trend-val {
  font-size: 10.5px;
  font-weight: 800;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.trend-track {
  flex: 1 1 auto;
  width: 100%;
  max-width: 40px;
  display: flex;
  align-items: flex-end;
  min-height: 0;
}

.trend-bar {
  width: 100%;
  min-height: 3px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 70%, #fff), var(--primary));
  transition: height 0.45s var(--ease), filter 0.2s;
}

.trend-col:hover .trend-bar { filter: brightness(1.08); }

.trend-col.is-current .trend-bar {
  background: linear-gradient(180deg, var(--primary-light), var(--primary-dark));
  box-shadow: var(--shadow-primary);
}

.trend-col.is-current .trend-val { color: var(--primary-dark); }

.trend-col.is-loss .trend-bar {
  background: linear-gradient(180deg, #f87171, #dc2626);
  border-radius: 2px 2px 6px 6px;
}

.trend-col.is-loss .trend-track { align-items: flex-start; }

.trend-col.is-loss .trend-val { color: #b91c1c; }

.trend-lbl {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ─── Calendar (mess invoices / meals) ─── */
.cal {
  --cal-gap: 6px;
  margin-top: 4px;
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.cal-head .cal-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-muted);
}

.cal-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cal-nav .btn { padding: 6px 12px; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--cal-gap);
}

.cal-dow {
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  padding: 2px 0 6px;
  letter-spacing: 0.01em;
}

.cal-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 60px;
  padding: 6px 2px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  font-size: 14px;
  line-height: 1.15;
  transition: transform var(--transition), border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.cal-cell:hover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-card));
  transform: translateY(-1px);
}

.cal-cell.is-empty {
  border-color: transparent;
  background: transparent;
  pointer-events: none;
}

.cal-cell.is-active {
  background: var(--primary);
  border-color: var(--primary-dark);
  color: #fff;
  box-shadow: var(--shadow-primary);
}

.cal-cell.is-today:not(.is-active) {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 28%, transparent);
}

.cal-cell .cal-mon {
  font-size: 9px;
  font-weight: 700;
  opacity: 0.65;
  line-height: 1;
}

.cal-cell .cal-amt {
  font-size: 9.5px;
  font-weight: 700;
  opacity: 0.8;
  font-variant-numeric: tabular-nums;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-cell.has-inv::after {
  content: "";
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #16a34a;
}

.cal-cell.is-active.has-inv::after { background: #fff; }

.cal-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.cal-legend .dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #16a34a;
  margin-inline-end: 5px;
}

/* ─── Table sort + export tools ─── */
.tbl-tools {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.tbl-tools .btn { padding: 5px 12px; font-size: 12px; }

table.data-table th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

table.data-table th.sortable::after {
  content: "↕";
  font-size: 9px;
  opacity: 0.3;
  margin-inline-start: 5px;
  display: inline-block;
}

table.data-table th.sortable.sort-asc::after { content: "▲"; opacity: 0.9; color: var(--primary); }
table.data-table th.sortable.sort-desc::after { content: "▼"; opacity: 0.9; color: var(--primary); }

/* ─── Command palette (Ctrl+K) ─── */
.k697-cmdk-overlay {
  position: fixed;
  inset: 0;
  z-index: 6500;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 16px 16px;
  background: rgba(6, 12, 18, 0.55);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.15s ease;
}

.k697-cmdk-overlay[hidden] { display: none; }

.k697-cmdk {
  width: min(620px, 100%);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.k697-cmdk-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.k697-cmdk-head .cmdk-ico { font-size: 16px; opacity: .6; }

.k697-cmdk-head input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.k697-cmdk-head input::placeholder { color: var(--text-muted); }

.k697-cmdk-head kbd {
  font: inherit;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  background: var(--bg-muted);
}

.k697-cmdk-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow: auto;
  min-height: 60px;
}

.k697-cmdk-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.k697-cmdk-item .cmdk-hint {
  margin-inline-start: auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  direction: ltr;
}

.k697-cmdk-item.is-active,
.k697-cmdk-item:hover {
  background: color-mix(in srgb, var(--accent) 15%, var(--bg-card));
  color: var(--primary-dark);
}

.k697-cmdk-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 13.5px;
}

.k697-cmdk-foot {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-muted);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

/* ─── Responsive polish ─── */
@media (max-width: 900px) {
  .status-strip { padding: 10px 12px; gap: 8px 10px; margin-bottom: 14px; }
  .status-strip .ss-sep { display: none; }
  .status-strip .ss-actions { width: 100%; margin-inline-start: 0; }
  .status-strip .ss-actions .btn { flex: 1; justify-content: center; }
  .stat-card { min-height: 0; }
}

@media (max-width: 640px) {
  .cal { --cal-gap: 4px; }
  .cal-cell { min-height: 46px; font-size: 12.5px; border-radius: 8px; padding: 4px 1px 6px; }
  .cal-cell .cal-amt { display: none; }
  .cal-dow { font-size: 9.5px; }
  .trend-bars { height: 92px; gap: 5px; }
  .trend-val { font-size: 9px; }
  .trend-lbl { font-size: 9px; }
  .tbl-tools { margin-bottom: 6px; }
}

@media (max-width: 420px) {
  .cal-cell { min-height: 42px; font-size: 12px; }
  .cal-cell .cal-mon { font-size: 8px; }
}

/* ═══════════════════════════════════════════════════════════
   Design v2 — currency typography, navigation, components
   ═══════════════════════════════════════════════════════════ */

/* ─── Currency unit rendered in the RTL text flow ─── */
.money-unit {
  font-size: max(9.5px, 0.62em);
  font-weight: 700;
  letter-spacing: 0;
  opacity: 0.68;
  margin-inline-start: 0.4em;
  white-space: nowrap;
  direction: rtl;
  unicode-bidi: isolate;
}

.stat-foot .money-unit,
.tile-note .money-unit,
.trend-cell .money-unit {
  opacity: 0.85;
  font-size: max(9.5px, 0.78em);
}

/* ─── KPI typography ─── */
.stat-value {
  font-size: clamp(19px, 2vw, 27px);
  letter-spacing: -0.015em;
  line-height: 1.2;
}

.stat-card { padding: 18px 20px 16px; }

.dash-tile .tile-value {
  font-size: clamp(22px, 2.6vw, 30px);
  letter-spacing: -0.025em;
}

/* ─── Stats grid: no orphan stretched columns ─── */
.stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(232px, 1fr));
}

/* ─── Sidebar active state ─── */
.nav-link {
  border-radius: 9px;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), padding-inline-start var(--transition);
}

.nav-link.active {
  background: linear-gradient(to left, color-mix(in srgb, var(--accent) 20%, transparent), color-mix(in srgb, var(--accent) 4%, transparent));
  color: #fff;
  box-shadow: none;
  font-weight: 800;
}

.nav-link.active::before {
  content: "";
  position: absolute;
  inset-inline-end: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 58%;
  border: 0;
  border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 60%, transparent);
  opacity: 1;
}

.nav-link.active::after { content: none; }

.nav-link.active .nav-icon { opacity: 1; }

/* ─── Topbar search affordance ─── */
.topbar-search::before {
  content: "";
  position: absolute;
  inset-inline-start: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  font-size: 0;
  opacity: 0.45;
  color: var(--text-muted);
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.7-3.7'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.7-3.7'/%3E%3C/svg%3E") center / contain no-repeat;
  pointer-events: none;
  transition: opacity var(--transition);
}

.topbar-search:focus-within::before { opacity: 0.8; }

.topbar-search input {
  border-radius: 999px;
  padding-inline-start: 40px;
  padding-inline-end: 16px;
}

.topbar-search input:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent), var(--shadow-xs);
}

/* ─── Quiet sort indicators ─── */
table.data-table th.sortable::after {
  content: "▲";
  font-size: 7px;
  opacity: 0;
  margin-inline-start: 5px;
  display: inline-block;
  transform: translateY(-1px);
  transition: opacity 0.15s ease;
}

table.data-table th.sortable:hover::after { opacity: 0.35; }

table.data-table th.sortable.sort-asc::after {
  content: "▲";
  opacity: 1;
  color: var(--primary);
}

table.data-table th.sortable.sort-desc::after {
  content: "▼";
  opacity: 1;
  color: var(--primary);
}

/* ─── Empty table rows ─── */
table.data-table tbody tr td[colspan]:only-child {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
  line-height: 1.75;
}

table.data-table tbody tr td[colspan]:only-child a {
  color: var(--primary-dark);
  font-weight: 800;
}

/* ─── Empty state component ─── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 30px 20px 32px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state .empty-ico {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-bottom: 6px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--accent) 9%, var(--bg-muted));
  color: color-mix(in srgb, var(--accent) 65%, var(--text-muted));
}

.empty-state .empty-ico svg { width: 22px; height: 22px; }

.empty-state .empty-title {
  font-size: 14.5px;
  font-weight: 800;
  color: var(--text);
}

.empty-state .empty-text {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.75;
  max-width: 44ch;
}

.empty-state .empty-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 8px;
}

.empty-state.is-compact {
  flex-direction: row;
  text-align: start;
  padding: 16px;
  gap: 12px;
}

.empty-state.is-compact .empty-ico { margin-bottom: 0; flex-shrink: 0; }

/* ─── Trend: bars + summary + empty ─── */
.trend-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 18px;
}

.trend-summary {
  display: grid;
  gap: 6px;
  min-width: 146px;
}

.trend-cell {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 1px 8px;
  padding: 7px 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-muted);
}

.trend-cell span {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.trend-cell strong {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.trend-cell em {
  grid-column: 1 / -1;
  font-style: normal;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  opacity: 0.85;
}

.trend-empty {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 16px;
  border-radius: 12px;
  border: 1px dashed color-mix(in srgb, var(--border) 80%, var(--text-muted));
  background: var(--bg-muted);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.7;
}

.trend-empty-ico {
  font-size: 20px;
  opacity: 0.65;
  flex-shrink: 0;
}

/* ─── Consistent keyboard focus ─── */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 72%, var(--primary));
  outline-offset: 2px;
}

/* ─── Page header rhythm ─── */
.page-header { margin-bottom: 20px; }

.page-title { font-size: clamp(22px, 2.2vw, 26px); }

/* ─── Responsive ─── */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
  .stat-value { font-size: clamp(18px, 3.6vw, 22px); }
  .trend-body { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .trend-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); min-width: 0; }
  .trend-cell { grid-template-columns: 1fr; gap: 2px; padding: 8px 10px; }
  .trend-cell span { font-size: 10px; }
  .trend-cell strong { font-size: 12px; }
}

@media (max-width: 560px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-value { font-size: 18px; }
  .stat-card { padding: 14px 14px 13px; }
  .stat-label { font-size: 12px; }
  .trend-summary { grid-template-columns: 1fr; }
  .trend-cell { grid-template-columns: 1fr auto; }
  .empty-state { padding: 22px 14px 24px; }
  .page-header { margin-bottom: 16px; }
}

/* ═══════════════════════════════════════════════════════════
   Design v3 — living dashboards
   sparkline · donut · meter · delta chips · leaderboards
   ═══════════════════════════════════════════════════════════ */

/* ─── Sparkline (inline SVG, no JS) ─── */
.spark {
  display: block;
  direction: ltr;
  width: 100%;
  height: 34px;
  margin-top: 10px;
  color: var(--stat-accent, var(--accent));
  opacity: 0.92;
}

.spark svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  transform: scaleX(-1);
}

.dash-tile--profit.is-up .spark { color: #16a34a; }
.dash-tile--profit.is-down .spark { color: #dc2626; }

.stat-card .spark { height: 30px; margin-top: 2px; opacity: 0.8; }

.dash-tile .spark { height: 36px; margin-top: 8px; opacity: 0.7; }

/* ─── Insight layout ─── */
.insight-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(292px, 1fr));
  gap: 14px;
  margin: 16px 0;
}

.insight-grid > .card + .card { margin-top: 0; }

.insight-card {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
}

.insight-card .card-header-row { margin-bottom: 14px; }

.insight-sub {
  margin: -6px 0 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.7;
}

.insight-card .rank-list + .meter {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

/* الكارت في شبكة 3 أعمدة أضيق من كارت عريض — الدونات يتكدس فوق التسمية بدل ما يزنقها */
.insight-card { container-type: inline-size; }

@container (max-width: 340px) {
  .insight-card .donut-wrap {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    gap: 14px;
  }
  .insight-card .donut-legend { width: 100%; }
  .insight-card .donut { width: 128px; height: 128px; }
  .insight-card .donut-lbl { white-space: normal; line-height: 1.35; }
}

.insight-facts {
  display: grid;
  gap: 7px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

.insight-facts > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.insight-facts b {
  font-size: 12.5px;
  font-weight: 900;
  color: var(--text);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.fact-list { display: grid; gap: 2px; }

.fact-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 8px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 700;
  transition: background var(--transition);
}

.fact-row:hover { background: var(--bg-muted); }

.fact-row .f-ico {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--bg-muted);
  font-size: 13px;
  transition: background var(--transition);
}

.fact-row:hover .f-ico { background: color-mix(in srgb, var(--accent) 16%, var(--bg-muted)); }

.fact-row .f-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fact-row b {
  font-size: 13px;
  font-weight: 900;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ─── Member status split ─── */
.member-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.ms-cell {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-muted);
}

.ms-cell strong {
  font-size: 22px;
  font-weight: 900;
  line-height: 1.1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.ms-cell span {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.ms-cell.ms-good { background: #ecfdf5; border-color: #bbf7d0; }
.ms-cell.ms-good strong { color: #15803d; }
.ms-cell.ms-bad { background: #fef2f2; border-color: #fecaca; }
.ms-cell.ms-bad strong { color: #b91c1c; }
.ms-cell.ms-zero strong { color: var(--text-muted); }

/* ─── Donut ─── */
.donut-wrap {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 22px;
}

.donut {
  position: relative;
  width: 152px;
  height: 152px;
  border-radius: 50%;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.06));
}

.donut-hole {
  position: absolute;
  inset: 23%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px;
  border-radius: 50%;
  background: var(--bg-card);
  box-shadow: 0 0 0 1px var(--border);
}

.donut-total {
  font-size: 14px;
  font-weight: 900;
  line-height: 1.2;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.donut-total .money-unit { opacity: 0.7; }

.donut-hole em {
  font-style: normal;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
}

.donut-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 7px;
  min-width: 0;
}

.donut-legend li {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
}

.donut-dot {
  width: 9px;
  height: 9px;
  border-radius: 3px;
}

.donut-lbl {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.donut-val {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.donut-val em {
  font-style: normal;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  margin-inline-start: 6px;
}

/* ─── Meter ─── */
.meter { display: grid; gap: 8px; }

.meter-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.meter-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-muted);
}

.meter-pct {
  font-size: 14px;
  font-weight: 900;
  color: var(--text);
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
}

.meter-track {
  height: 9px;
  border-radius: 999px;
  background: var(--bg-muted);
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.meter-fill {
  position: relative;
  display: block;
  height: 100%;
  border-radius: inherit;
  overflow: hidden;
  background: linear-gradient(to left, var(--primary), var(--accent));
  transition: width 0.7s var(--ease);
}

.meter-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  animation: k697Sheen 3.4s var(--ease) infinite;
}

@keyframes k697Sheen {
  0% { transform: translateX(-100%); }
  55%, 100% { transform: translateX(220%); }
}

.meter-foot {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.7;
}

.meter.good .meter-fill { background: linear-gradient(to left, #15803d, #4ade80); }
.meter.warn .meter-fill { background: linear-gradient(to left, #b45309, #fbbf24); }
.meter.bad  .meter-fill { background: linear-gradient(to left, #b91c1c, #f87171); }
.meter.info .meter-fill { background: linear-gradient(to left, var(--primary), var(--accent)); }
.meter.good .meter-pct { color: #15803d; }
.meter.warn .meter-pct { color: #b45309; }
.meter.bad  .meter-pct { color: #b91c1c; }

/* ─── Delta chip ─── */
.delta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-muted);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 800;
  vertical-align: middle;
  white-space: nowrap;
  line-height: 1.5;
}

.delta-chip .delta-pct {
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
}

.delta-chip small { font-size: 10px; font-weight: 600; opacity: 0.8; }
.delta-chip.up   { background: #ecfdf5; color: #15803d; }
.delta-chip.down { background: #fef2f2; color: #b91c1c; }

/* ─── Leaderboard / rank list ─── */
.rank-list { list-style: none; margin: 0; padding: 0; }

.rank-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}

.rank-row:last-child { border-bottom: 0; padding-bottom: 0; }
.rank-row:first-child { padding-top: 0; }

.rank-no {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: var(--bg-muted);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 900;
}

.rank-row:nth-child(1) .rank-no { background: #fef3c7; color: #92400e; }
.rank-row:nth-child(2) .rank-no { background: #e2e8f0; color: #334155; }
.rank-row:nth-child(3) .rank-no { background: #ffedd5; color: #9a3412; }

.rank-main { min-width: 0; display: grid; gap: 6px; }

.rank-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.rank-name {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-amt {
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.rank-track {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-muted);
  overflow: hidden;
}

.rank-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(to left, var(--primary), var(--accent));
}

.rank-row.is-warn .rank-fill { background: linear-gradient(to left, #b45309, #fbbf24); }
.rank-row.is-bad  .rank-fill { background: linear-gradient(to left, #b91c1c, #f87171); }

.rank-empty {
  padding: 16px 0;
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.insight-card > .rank-empty {
  display: grid;
  place-items: center;
  flex: 1;
  min-height: 152px;
  padding: 18px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: var(--bg-muted);
}

/* ─── Table row readiness ─── */
table.data-table tbody tr td:first-child {
  border-inline-start: 3px solid transparent;
  transition: border-color var(--transition);
}

table.data-table tbody tr:hover td:first-child {
  border-inline-start-color: color-mix(in srgb, var(--accent) 65%, transparent);
}

/* ─── Entrance motion ─── */
@keyframes k697Rise {
  from { opacity: 0; transform: translateY(9px); }
  to   { opacity: 1; transform: translateY(0); }
}

.stats-grid > *,
.dash-bento > *,
.dash-metrics > *,
.dash-panels > *,
.insight-grid > *,
.console-grid > * {
  animation: k697Rise 0.48s var(--ease) backwards;
}

.stats-grid > *:nth-child(2),
.dash-bento > *:nth-child(2),
.dash-metrics > *:nth-child(2),
.insight-grid > *:nth-child(2) { animation-delay: 0.04s; }
.stats-grid > *:nth-child(3),
.dash-bento > *:nth-child(3),
.dash-metrics > *:nth-child(3),
.insight-grid > *:nth-child(3) { animation-delay: 0.08s; }
.stats-grid > *:nth-child(4),
.dash-bento > *:nth-child(4),
.dash-metrics > *:nth-child(4) { animation-delay: 0.12s; }
.stats-grid > *:nth-child(5),
.dash-bento > *:nth-child(5),
.dash-metrics > *:nth-child(5) { animation-delay: 0.16s; }
.stats-grid > *:nth-child(6),
.dash-bento > *:nth-child(6),
.dash-metrics > *:nth-child(6) { animation-delay: 0.2s; }
.stats-grid > *:nth-child(n+7),
.dash-bento > *:nth-child(n+7),
.dash-metrics > *:nth-child(n+7) { animation-delay: 0.24s; }

/* ─── Responsive ─── */
@media (max-width: 900px) {
  .donut { width: 136px; height: 136px; }
  .donut-wrap { gap: 18px; }
}

@media (max-width: 560px) {
  .insight-grid { gap: 12px; }
  .insight-card > .rank-empty { min-height: 96px; flex: 0 0 auto; }
  .donut-wrap { grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 16px; }
  .donut-legend { width: 100%; }
  .stat-card .spark { height: 26px; }
  .dash-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .delta-chip small { display: none; }
}

/* ═══════════════════════════════════════════════════════════
   Micro-polish pass — quiet rows, steady control rhythm
   ═══════════════════════════════════════════════════════════ */

/* ─── Row actions: soft chips instead of solid saturated buttons ─── */
table.data-table td .btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  margin: 2px;
  padding: 3px 10px;
  border-radius: 8px;
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0;
  box-shadow: none;
  border: 1px solid transparent;
  vertical-align: middle;
}

table.data-table td .btn-sm .kicon { width: 13px; height: 13px; }
table.data-table td form { display: inline; }

table.data-table td .btn-primary,
table.data-table td .btn-info,
table.data-table td .btn-muted {
  background: color-mix(in srgb, var(--primary) 9%, var(--bg-card));
  border-color: color-mix(in srgb, var(--primary) 20%, transparent);
  color: var(--primary-dark);
}

table.data-table td .btn-success {
  background: var(--success-bg);
  border-color: color-mix(in srgb, var(--success) 24%, transparent);
  color: color-mix(in srgb, var(--success) 70%, #000);
}

table.data-table td .btn-warning {
  background: var(--warning-bg);
  border-color: color-mix(in srgb, var(--warning) 30%, transparent);
  color: color-mix(in srgb, var(--warning) 68%, #000);
}

table.data-table td .btn-danger {
  background: var(--danger-bg);
  border-color: color-mix(in srgb, var(--danger) 24%, transparent);
  color: var(--danger);
}

table.data-table td .btn-sm:hover { transform: none; filter: brightness(0.965); }

/* ─── Cells that must never break mid-value ─── */
table.data-table td .money-num { white-space: nowrap; }

/* ─── Inputs living inside a row stay compact; page forms keep 44px ─── */
table.data-table td input.field,
table.data-table td select.field {
  min-height: 34px;
  padding: 5px 10px;
  font-size: var(--fs-sm);
  border-radius: 9px;
}

input.field,
select.field { min-height: 44px; }

textarea.field { min-height: 96px; }

/* ─── Zero/empty KPI cards step back so the real numbers lead ───
   !important is deliberate: several pages still colour these cards inline. */
.stat-card.is-zero {
  background: var(--bg-inset) !important;
  border-color: var(--border) !important;
  box-shadow: none !important;
  color: var(--text-muted) !important;
}

.stat-card.is-zero::before { opacity: 0.22; }
.stat-card.is-zero::after { opacity: 0.12; }
.stat-card.is-zero .stat-value { color: var(--text-faint) !important; }
.stat-card.is-zero .stat-label { color: var(--text-faint) !important; }
.stat-card.is-zero .stat-foot { color: var(--text-faint); border-top-color: var(--border); }

.stat-card.is-zero .stat-icon {
  color: var(--text-faint);
  background: color-mix(in srgb, var(--text-faint) 12%, var(--bg-card));
  box-shadow: inset 0 0 0 1px var(--border);
}

.stat-card.is-zero:hover { transform: none; box-shadow: none; border-color: var(--border); }
.stat-card.is-zero:hover::after { opacity: 0.12; }

/* ─── Card/section headers: keep the icon tight against its title ─── */
.card h3 .kicon,
.page-title .kicon { margin-inline-end: 6px; vertical-align: -0.16em; }

/* التاريخ المعروض d/m/Y دائماً (k697-ui.js يحول صيغة التخزين ISO) */
.k697-date {
  white-space: nowrap;
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
}

/* A lead KPI: the accent bar grows instead of stacking a second inline border on top. */
.stat-card--lead::before { height: 6px; }
.stat-card--lead .stat-label { font-weight: 800; }
.stat-card--lead .stat-value { font-weight: 900; }
.stat-card--lead.stat-card-wide .stat-value { font-size: 28px; }

@media (max-width: 900px) {
  .stat-card--lead.stat-card-wide .stat-value { font-size: 20px; }
}

/* ─── Emphasis card + quiet note panel (replaces the shouty 3px/dashed inline cards) ─── */
.card--focus {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: linear-gradient(165deg, var(--bg-card) 0%, color-mix(in srgb, var(--accent) 13%, var(--bg-card)) 100%);
  box-shadow: var(--shadow);
}

.card--focus > h2:first-child,
.card--focus > h3:first-child { color: color-mix(in srgb, var(--primary-dark) 82%, #000); }

.card--ghost,
.note-box {
  border: 1px dashed var(--border-strong);
  background: var(--bg-inset);
  color: var(--text-muted);
}

.note-box {
  margin-top: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1.9;
  color: var(--text-muted);
}

.note-box--warn {
  border-color: color-mix(in srgb, var(--warning) 45%, transparent);
  background: var(--warning-bg);
  color: #92400e;
}

.note-box--info {
  border-color: color-mix(in srgb, var(--primary) 40%, transparent);
  background: color-mix(in srgb, var(--primary) 7%, var(--bg-card));
  color: var(--primary-dark);
}

.formula-box {
  padding: 14px;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border-accent);
  background: var(--bg-card);
}

.formula-box__line {
  margin-top: 10px;
  font-size: var(--fs-md);
  font-weight: 900;
  direction: ltr;
  text-align: center;
  letter-spacing: 0.5px;
  line-height: 2.2;
}

.explain-list {
  margin: 10px 0 0;
  margin-inline-start: 24px;
  color: var(--text-muted);
  line-height: 2.2;
}

.explain-list li { margin-bottom: 4px; }
