@import url("https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700&display=swap");

:root {
  --primary: #0F172A;
  --primary-light: #06B6D4;
  --primary-pale: #E0F7FB;
  --accent: #10B981;
  --gold: #10B981;
  --gold-light: #D1FAE5;
  --bg: #F8FAFC;
  --surface: #F1F5F9;
  --panel: #FFFFFF;
  --text: #0F172A;
  --muted: #64748B;
  --line: #E2E8F0;
  --danger: #C0392B;
  --danger-light: #FDECEA;
  --warning: #E67E22;
  --warning-light: #FEF3E2;
  --success: #27AE60;
  --success-light: #E9F7EF;
  --info: #2980B9;
  --info-light: #EBF5FB;
  --purple: #8E44AD;
  --purple-light: #F4ECF7;
  --shadow: 0 2px 12px rgba(15, 23, 42, .08);
  --shadow-lg: 0 8px 32px rgba(15, 23, 42, .13);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 230px;
}

.dashboard-pro {
  display: grid;
  gap: 16px;
  width: 100%;
}

.dashboard-hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  min-height: 154px;
  padding: 24px;
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(15, 23, 42, .96), rgba(15, 23, 42, .86)),
    linear-gradient(90deg, rgba(6, 182, 212, .24), rgba(16, 185, 129, .18));
  color: #fff;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.dashboard-kicker {
  display: inline-flex;
  padding: 4px 9px;
  margin-bottom: 9px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 999px;
  color: #bdebf2;
  font-size: 12px;
  font-weight: 700;
}

.dashboard-hero h2 {
  color: #fff;
  font-size: 30px;
  font-weight: 800;
  margin-bottom: 6px;
}

.dashboard-hero p {
  color: rgba(255,255,255,.78);
  font-size: 13px;
}

.dashboard-hero-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.dashboard-hero-actions .btn.secondary,
.dashboard-hero-actions .btn.ghost {
  border-color: rgba(255,255,255,.42);
  background: rgba(255,255,255,.10);
  color: #fff;
}

.dashboard-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric-tile {
  min-height: 118px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow);
  display: grid;
  align-content: space-between;
  overflow: hidden;
  position: relative;
}

.metric-tile::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  width: 4px;
  height: 100%;
  background: var(--primary-light);
}

.metric-tile.success::before { background: var(--success); }
.metric-tile.gold::before { background: #d69e2e; }
.metric-tile.purple::before { background: var(--purple); }

.metric-tile span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-tile strong {
  font-size: 30px;
  line-height: 1;
  color: var(--primary);
}

.metric-tile small {
  color: var(--muted);
  font-size: 12px;
}

.dashboard-main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(330px, .85fr);
  gap: 14px;
}

.dashboard-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  box-shadow: var(--shadow);
  align-self: start;
}

.dashboard-wide {
  width: 100%;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 13px;
}

.panel-head h3 {
  font-size: 16px;
  color: var(--primary);
}

.panel-head p {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.command-panel {
  min-height: 252px;
}

.progress-ring {
  --value: 0;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: conic-gradient(var(--accent) calc(var(--value) * 1%), #e8eef5 0);
  display: grid;
  place-items: center;
}

.progress-ring strong {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fff;
  color: var(--primary);
  font-size: 18px;
}

.signal-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.signal-grid div,
.business-pulse div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
  display: grid;
  gap: 3px;
}

.signal-grid span,
.business-pulse span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.signal-grid strong,
.business-pulse strong {
  font-size: 20px;
  color: var(--primary);
}

.premium-list {
  display: grid;
  gap: 8px;
}

.premium-row {
  width: 100%;
  text-align: inherit;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  display: grid;
  gap: 2px;
  color: var(--text);
}

.premium-row:hover {
  border-color: var(--primary-light);
  background: #f8fdff;
}

.premium-row strong {
  font-size: 13px;
}

.premium-row span,
.premium-row small {
  color: var(--muted);
  font-size: 12px;
}

.workload-row {
  display: grid;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.workload-row:last-child {
  border-bottom: 0;
}

.workload-row div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.workload-row span {
  color: var(--muted);
  font-size: 12px;
}

.workload-bar {
  height: 8px;
  border-radius: 999px;
  background: #edf2f7;
  overflow: hidden;
}

.workload-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary-light), var(--accent));
}

.business-pulse {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

@media (max-width: 1100px) {
  .dashboard-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-main-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .dashboard-hero {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px;
  }

  .dashboard-hero h2 {
    font-size: 24px;
  }

  .dashboard-hero-actions {
    justify-content: flex-start;
  }

  .dashboard-metrics,
  .signal-grid,
  .business-pulse {
    grid-template-columns: 1fr;
  }

  .panel-head {
    display: grid;
  }
}

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

body {
  font-family: "Cairo", Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
  direction: rtl;
  overflow-x: hidden;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h1 { font-size: 22px; font-weight: 700; color: var(--primary); }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
.muted { color: var(--muted); }

.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  padding: 20px;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px 36px;
  width: 400px;
  max-width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .20);
}

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

.login-card .brand {
  flex-direction: column;
  text-align: center;
  gap: 10px;
}

.brand-logo,
.brand-mark {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  object-fit: cover;
  background: var(--primary-pale);
}

.sidebar .brand-logo,
.sidebar .brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(255,255,255,.15);
}

.version-badge {
  margin-top: 12px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.app-version {
  margin-top: 3px;
  color: rgba(255,255,255,.7);
  font-size: 11px;
  font-weight: 600;
}

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
}

input, select, textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  background: #fff;
  outline: none;
  direction: rtl;
  transition: border .15s;
}

input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { min-height: 82px; resize: vertical; }

.searchable-client {
  position: relative;
}

.client-search-hint {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 12px;
  font-weight: 500;
  transition: all .15s;
  background: var(--primary);
  color: #fff;
}

.btn:hover:not(:disabled) { background: #111827; }
.btn.secondary { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.btn.secondary:hover:not(:disabled) { background: var(--primary-pale); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.alert {
  background: var(--danger-light);
  color: var(--danger);
  padding: 10px;
  border-radius: 8px;
  font-size: 12px;
  margin-bottom: 12px;
  text-align: center;
}

.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
  padding: 0;
}

.sidebar .brand {
  padding: 24px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  margin: 0;
  align-items: flex-start;
}

.sidebar .brand h3 {
  color: #fff;
  font-size: 19px;
  font-weight: 700;
}

.nav {
  padding: 12px 0;
  flex: 1;
  display: block;
}

.nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 400;
  opacity: .82;
  border: none;
  background: none;
  color: #fff;
  width: 100%;
  text-align: right;
  transition: all .15s;
}

.nav button:hover { background: rgba(255,255,255,.10); opacity: 1; }
.nav button.active {
  background: rgba(255,255,255,.18);
  opacity: 1;
  font-weight: 600;
  border-right: 3px solid var(--accent);
}

.user-box {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,.12);
  display: grid;
  gap: 8px;
}

.user-box .btn.ghost {
  background: rgba(255,255,255,.15);
  color: #fff;
  border: none;
  padding: 7px 8px;
}

.main {
  margin-right: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 0 32px;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-subtitle { font-size: 11px; margin-top: 2px; }
.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}
.language-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.language-picker select {
  width: auto;
  min-width: 92px;
  height: 38px;
  padding: 0 9px;
}
.content {
  padding: 20px 24px;
  flex: 1;
  display: grid;
  gap: 12px;
  align-content: start;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 9px 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

.toolbar input { width: 220px; }
.toolbar select { width: 150px; }

.inline-check {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
}

.inline-check input {
  width: auto;
  min-height: 0;
}

.inline-check input[type="number"] {
  width: 64px;
  height: 30px;
  padding: 0 7px;
}

.grid { display: grid; gap: 12px; }
.stats {
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 86px;
  align-items: stretch;
  margin-bottom: 6px;
}

.content > .stats,
.report-content > .stats {
  align-self: start;
}

.card {
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  align-self: start;
}

.card h3 { margin-bottom: 10px; }

.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 15px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  height: 86px;
  min-height: 0;
  max-height: 86px;
  overflow: hidden;
}

.stat-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.stat-icon.green { background: var(--primary-pale); }
.stat-icon.gold { background: var(--gold-light); }
.stat-icon.blue { background: var(--info-light); }
.stat-icon.red { background: var(--danger-light); }
.stat-icon.purple { background: var(--purple-light); }

.stats > .card { min-height: 0; }

.stat-value {
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
  color: var(--text);
}

.stat-label {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Unified compact page rhythm */
.content > .card,
.content > .table-wrap,
.content > .reports-shell,
.content > .toolbar {
  width: 100%;
}

.content .card + .table-wrap,
.content .toolbar + .card,
.content .toolbar + .table-wrap {
  margin-top: 0;
}

.content > .card .table-wrap {
  box-shadow: none;
  border-radius: var(--radius-sm);
}

.content > .card:has(.table-wrap) {
  padding: 12px;
}

.content > .card:has(.table-wrap) h3 {
  padding: 0 4px;
}

select,
input[type="date"],
input[type="time"],
input[type="number"] {
  min-height: 36px;
}

input,
textarea {
  min-height: 36px;
}

textarea {
  min-height: 72px;
}

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  align-self: start;
}

.responsive-table td[data-label]::before {
  display: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

tbody tr {
  height: 42px;
}

th {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-align: right;
  padding: 7px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #F1F5F9; }

.actions { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.actions .btn { padding: 4px 9px; font-size: 11.5px; }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.pill.done { background: var(--success-light); color: var(--success); }
.pill.pending { background: var(--info-light); color: var(--info); }
.pill.cancelled { background: var(--danger-light); color: var(--danger); }

.rank-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.reports-shell .table-wrap,
.reports-shell .card {
  box-shadow: none;
}

.reports-shell .stats {
  margin-bottom: 0;
}

.rank-row:last-child { border-bottom: none; }
.rank-row span { flex: 1; font-size: 13px; font-weight: 500; }
.rank-row strong { font-size: 13px; font-weight: 600; color: var(--primary); }

.reports-shell {
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
  align-self: start;
}

.reports-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 16px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  background: var(--bg);
}

.rtab {
  padding: 7px 12px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid transparent;
  border-bottom: none;
  transition: all .15s;
  background: transparent;
}

.rtab:hover { color: var(--primary); background: var(--primary-pale); }
.rtab.active {
  color: var(--primary);
  background: #fff;
  border-color: var(--line);
  font-weight: 600;
}

.filter-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.report-content {
  padding: 14px;
  display: grid;
  gap: 12px;
  align-content: start;
}
.report-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.export-btns { display: flex; gap: 8px; flex-wrap: wrap; }

.report-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.report-alert.warning { background: var(--warning-light); color: var(--warning); border-right: 3px solid var(--warning); }
.report-alert.success { background: var(--success-light); color: var(--success); border-right: 3px solid var(--success); }

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,.4);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-card {
  background: #fff;
  border-radius: var(--radius);
  width: 520px;
  max-width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  direction: rtl;
}

.modal-head {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.modal-body {
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
}

.modal-body .full { grid-column: 1 / -1; }
.modal-foot {
  padding: 13px 18px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
  position: sticky;
  bottom: 0;
  background: #fff;
}

.center-error-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(10, 22, 20, .38);
}

.center-error-card {
  width: min(620px, 92vw);
  display: grid;
  gap: 18px;
  justify-items: center;
  padding: 30px 28px;
  border: 1px solid #f4c7c3;
  border-radius: 10px;
  background: #fff;
  color: var(--danger);
  box-shadow: 0 24px 70px rgba(29, 47, 43, .24);
  text-align: center;
}

.center-error-card strong {
  font-size: 24px;
  line-height: 1.65;
}

.hidden { display: none !important; }

.quick-search {
  position: relative;
  width: clamp(220px, 28vw, 360px);
  min-width: 0;
}

.quick-search input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
}

.quick-results {
  position: fixed;
  top: 72px;
  left: 12px;
  right: auto;
  width: min(420px, calc(100vw - var(--sidebar-w) - 64px));
  max-width: calc(100vw - var(--sidebar-w) - 64px);
  max-height: min(520px, calc(100vh - 88px));
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  z-index: 20;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.quick-results button {
  min-width: 0;
  width: 100%;
  border: 0;
  background: #fff;
  padding: 10px 12px;
  display: grid;
  gap: 3px;
  text-align: right;
  cursor: pointer;
}

.quick-results button:hover { background: var(--surface); }
.quick-results span { color: var(--muted); font-size: 12px; }
.quick-group { border-bottom: 1px solid var(--line); padding: 6px; }
.quick-group:last-child { border-bottom: 0; }
.quick-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  padding: 5px 7px;
}
.quick-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: stretch;
}
.quick-item strong,
.quick-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.quick-action {
  width: auto !important;
  min-width: 58px;
  border-radius: 7px;
  background: var(--primary-pale) !important;
  color: var(--primary);
  text-align: center !important;
}
.quick-empty {
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
}

.calendar-shell { display: grid; gap: 14px; }
.calendar-toolbar { align-items: center; justify-content: space-between; }
.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.segmented button {
  border: 0;
  background: transparent;
  padding: 9px 14px;
  cursor: pointer;
}
.segmented button.active { background: var(--primary); color: #fff; }
.calendar-nav { display: flex; gap: 8px; }
.calendar-grid {
  display: grid;
  gap: 10px;
}
.calendar-grid.month { grid-template-columns: repeat(7, minmax(120px, 1fr)); }
.calendar-grid.week { grid-template-columns: repeat(7, minmax(140px, 1fr)); }
.calendar-grid.day { grid-template-columns: 1fr; }
.calendar-day {
  min-height: 138px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
  cursor: pointer;
}
.calendar-grid.day .calendar-day { min-height: 520px; }
.calendar-day.today { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.calendar-day header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}
.calendar-day header strong { color: var(--text); font-size: 18px; }
.calendar-events { display: grid; align-content: start; gap: 6px; }
.calendar-event {
  border: 0;
  border-radius: 7px;
  padding: 8px;
  text-align: right;
  background: var(--primary-light);
  color: var(--text);
  cursor: pointer;
  display: grid;
  gap: 2px;
}
.calendar-event.done { background: var(--success-light); }
.calendar-event.cancelled { background: var(--danger-light); }
.calendar-event span, .calendar-event em { font-size: 11px; color: var(--muted); font-style: normal; }
.calendar-empty { color: var(--muted); font-size: 12px; }

.calendar-card {
  overflow-x: auto;
}

.calendar-legend {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.calendar-legend span {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--muted);
}

.calendar-month {
  display: grid;
  grid-template-columns: repeat(7, minmax(132px, 1fr));
  gap: 8px;
  min-width: 920px;
}

.calendar-week {
  display: grid;
  grid-template-columns: 160px repeat(7, minmax(132px, 1fr));
  gap: 8px;
  min-width: 1080px;
}

.calendar-day-board {
  display: grid;
  grid-template-columns: 92px repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
  min-width: 760px;
}

.calendar-corner,
.calendar-weekday,
.calendar-resource,
.calendar-hour {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 8px;
  font-size: 12px;
  color: var(--muted);
}

.calendar-weekday.strong,
.calendar-resource strong {
  color: var(--text);
}

.calendar-resource {
  display: grid;
  gap: 2px;
  align-content: center;
}

.calendar-resource.header {
  background: #fff;
}

.calendar-hour {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--text);
}

.calendar-day-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
}

.calendar-day.outside {
  opacity: .48;
}

.calendar-slot {
  min-height: 88px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  display: grid;
  gap: 6px;
  align-content: start;
  cursor: pointer;
}

.calendar-slot:hover,
.calendar-day:hover {
  border-color: var(--primary);
}

.pill.paid { background: var(--success-light); color: var(--success); }
.pill.unpaid { background: var(--danger-light); color: var(--danger); }
.pill.deposit { background: var(--warning-light); color: var(--warning); }

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, .8fr);
  gap: 16px;
}
.settings-grid form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.settings-grid form .full, .settings-grid form button { grid-column: 1 / -1; }
.logo-upload {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 10px;
  align-items: center;
}
.logo-upload img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 6px;
}
.work-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(90px, 1fr));
  gap: 8px;
}
.work-days label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
}
.backup-panel {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
}
.modal-card.wide { width: min(980px, 96vw); }
.client-profile {
  grid-template-columns: repeat(3, 1fr);
}
.card.mini {
  box-shadow: none;
  padding: 12px;
  display: grid;
  gap: 5px;
}
.profile-section {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
}
.file-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.inline-form {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr auto;
  gap: 8px;
}
.inline-form input {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
}
.upload-form input[type="file"] {
  padding: 8px 10px;
  height: auto;
  background: #fff;
}
.upload-hint {
  font-size: 11px;
}

.feature-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
  gap: 14px;
}

.stack-list {
  display: grid;
  gap: 10px;
}

.feature-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.feature-row div:first-child {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.feature-row span,
.feature-row small {
  color: var(--muted);
  font-size: 12px;
}

.platform-tenant-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(280px, auto);
  align-items: start;
}

.platform-billing-panel {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  width: 100%;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.platform-password-form {
  grid-column: 1 / -1;
  width: 100%;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.platform-password-form strong {
  font-size: 13px;
}

.platform-billing-panel h4 {
  margin: 0;
  font-size: 14px;
}

.platform-billing-panel .compact {
  gap: 8px;
}

.invoice-row {
  border-radius: 8px;
  background: #fff;
}

.pdf-preview {
  width: 100%;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.signature-pad {
  width: 100%;
  height: 180px;
  border: 1px dashed var(--primary);
  border-radius: 10px;
  background: #fff;
  touch-action: none;
}

.gift-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.gift-card {
  position: relative;
  min-height: 260px;
  padding: 26px 18px 18px;
  border: 1px solid #d7eadf;
  border-radius: 16px;
  background: linear-gradient(145deg, #ffffff 0%, #f1faf5 100%);
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
  align-content: start;
  overflow: hidden;
}

.gift-card::before {
  content: "";
  position: absolute;
  inset-inline-start: -34px;
  top: 22px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--primary-pale);
}

.gift-card > * {
  position: relative;
}

.gift-ribbon {
  justify-self: start;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--gold-light);
  color: #8a6324;
  font-weight: 700;
  font-size: 12px;
}

.gift-card code {
  padding: 10px;
  border: 1px dashed var(--primary);
  border-radius: 10px;
  background: #fff;
  text-align: center;
  direction: ltr;
}

@media (max-width: 900px) {
  :root { --sidebar-w: 100%; }
  .shell {
    display: block;
    min-width: 0;
  }
  .sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    height: auto;
    max-height: none;
    z-index: 120;
    overflow: visible;
    box-shadow: 0 8px 22px rgba(16, 34, 32, .14);
  }
  .sidebar .brand {
    padding: 12px 16px 8px;
    margin: 0;
    align-items: center;
  }
  .sidebar .brand-logo,
  .sidebar .brand-mark {
    width: 34px;
    height: 34px;
  }
  .sidebar .brand h3 {
    font-size: 16px;
  }
  .sidebar .brand div div:not(.app-version) {
    font-size: 11px !important;
  }
  .app-version {
    font-size: 10px;
  }
  .nav {
    display: flex;
    gap: 6px;
    padding: 8px 10px 10px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
  }
  .nav button {
    width: auto;
    flex: 0 0 auto;
    min-height: 38px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    white-space: nowrap;
    opacity: .9;
  }
  .nav button.active {
    border-right: 0;
    box-shadow: inset 0 -3px 0 var(--accent);
  }
  .user-box {
    display: none;
  }
  .main {
    margin-right: 0;
    width: 100%;
    min-width: 0;
  }
  .topbar {
    position: sticky;
    top: 0;
    min-height: auto;
    padding: 12px 16px;
    align-items: flex-start;
    gap: 10px;
    flex-wrap: wrap;
  }
  .topbar > div:first-child {
    min-width: min(100%, 260px);
  }
  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }
  .language-picker {
    flex: 0 0 auto;
  }
  .quick-search {
    flex: 1 1 240px;
    width: auto;
  }
  .content { padding: 14px; }
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: 82px;
  }
  .stat-card {
    height: 82px;
    max-height: 82px;
    padding: 11px 12px;
  }
  .stat-value { font-size: 18px; }
  .report-grid-2 { grid-template-columns: 1fr; }
  .calendar-toolbar {
    align-items: stretch;
  }
  .calendar-toolbar,
  .calendar-nav,
  .segmented {
    width: 100%;
  }
  .calendar-nav,
  .segmented {
    justify-content: center;
  }
  .calendar-grid.month, .calendar-grid.week {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .calendar-day {
    min-height: 150px;
  }
  .settings-grid, .client-profile, .feature-grid { grid-template-columns: 1fr; }
  .inline-form, .file-row { grid-template-columns: 1fr; }
  .work-days { grid-template-columns: repeat(2, 1fr); }
  .modal {
    padding: 12px;
    align-items: start;
    overflow-y: auto;
  }
  .modal-card,
  .modal-card.wide {
    width: min(100%, 720px);
    max-height: calc(100vh - 24px);
  }
  .quick-results {
    width: min(420px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    top: 118px;
    left: 12px;
  }
}

@media (max-width: 600px) {
  body { font-size: 13px; }
  h2 { font-size: 17px; }
  .login { padding: 14px; }
  .login-card {
    padding: 28px 20px;
    border-radius: 12px;
  }
  .sidebar .brand {
    padding: 10px 12px 6px;
  }
  .nav {
    padding: 7px 8px 9px;
  }
  .nav button {
    min-height: 36px;
    padding: 7px 10px;
    font-size: 12px;
  }
  .content {
    padding: 10px;
    gap: 10px;
  }
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: 70px;
  }
  .stat-card {
    height: 70px;
    max-height: 70px;
    padding: 9px;
    gap: 8px;
    border-radius: 10px;
  }
  .stat-icon {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    font-size: 12px;
  }
  .stat-value {
    font-size: 15px;
    margin-bottom: 2px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .stat-label {
    font-size: 10px;
    line-height: 1.2;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .toolbar {
    padding: 10px;
  }
  .toolbar input, .toolbar select, .toolbar .btn {
    width: 100%;
  }
  .topbar {
    padding: 10px;
  }
  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
  .language-picker,
  .language-picker select {
    width: 100%;
  }
  .quick-search {
    width: 100%;
    min-width: 0;
  }
  .quick-results {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    top: 150px;
    left: 10px;
    right: auto;
  }
  .card {
    padding: 10px;
    border-radius: 10px;
  }
  .table-wrap {
    border-radius: 10px;
  }
  .responsive-table {
    overflow-x: visible;
    background: transparent;
    border: 0;
    box-shadow: none;
  }
  .responsive-table table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0 8px;
  }
  .responsive-table thead {
    display: none;
  }
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table td {
    display: block;
    width: 100%;
  }
  .responsive-table tbody tr {
    height: auto;
    margin: 0 0 8px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    box-shadow: var(--shadow-soft);
  }
  .responsive-table td {
    border-bottom: 0;
    padding: 5px 0;
    display: grid;
    grid-template-columns: minmax(86px, 38%) minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    font-size: 12px;
    line-height: 1.35;
    white-space: normal;
    word-break: break-word;
  }
  .responsive-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
  }
  .responsive-table td[colspan] {
    display: block;
    text-align: center;
  }
  .responsive-table td[colspan]::before {
    content: none;
  }
  .responsive-table td.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-start;
    padding-top: 8px;
  }
  .responsive-table td.actions::before {
    content: none;
  }
  .responsive-table td.actions .btn {
    flex: 1 1 92px;
    min-width: 0;
  }
  table {
    min-width: 680px;
  }
  th, td {
    padding: 7px 8px;
  }
  .actions .btn {
    min-height: 30px;
  }
  .modal {
    padding: 8px;
  }
  .modal-card,
  .modal-card.wide {
    width: 100%;
    max-height: calc(100vh - 16px);
    border-radius: 10px;
  }
  .modal-head {
    padding: 12px;
    gap: 8px;
  }
  .modal-head h3 {
    font-size: 14px;
  }
  .modal-body {
    grid-template-columns: 1fr;
    padding: 12px;
  }
  .modal-foot {
    padding: 12px;
    flex-direction: column;
    align-items: stretch;
  }
  .modal-foot .btn,
  .modal-foot button {
    width: 100%;
  }
  .center-error-card {
    padding: 22px 18px;
  }
  .center-error-card strong {
    font-size: 18px;
  }
  .calendar-grid.month, .calendar-grid.week { grid-template-columns: 1fr; }
  .calendar-day {
    min-height: 128px;
  }
  .calendar-grid.day .calendar-day {
    min-height: 360px;
  }
  .settings-grid form { grid-template-columns: 1fr; }
  .logo-upload, .work-days { grid-template-columns: 1fr; }
  .reports-tabs,
  .filter-row,
  .report-content {
    padding-inline: 10px;
  }
  .rtab {
    flex: 1 0 auto;
    text-align: center;
  }
}

@media (max-width: 360px) {
  .stats {
    grid-template-columns: 1fr;
  }
  .stat-card {
    height: 64px;
    max-height: 64px;
  }
}
