/* ==========================================================================
   Cosmic — מערכת העיצוב
   ורוד עמום על נייר חמים. הוורוד שמור לפעולה, להיום ולעכשיו בלבד;
   כל השאר נייר ודיו. מצב ערב זמין דרך data-theme="dark".
   ========================================================================== */

:root {
  --paper:      #FDF7F9;
  --surface:    #FFFFFF;
  --surface-2:  #FCF2F5;
  --ink:        #2E1F2A;
  --ink-2:      #5A4553;
  --muted:      #8C7885;
  --line:       #F2E4EA;
  --line-2:     #F9EFF3;
  --wash:       rgba(196,80,111,.08);

  --rose:       #C4506F;
  --rose-press: #A93E5B;
  --rose-soft:  #F9E7ED;
  --rose-tint:  #FDF3F6;

  --sand:       #B98A5E;
  --mulberry:   #8E5E96;
  --teal:       #3E8E7E;
  --amber:      #C98A2B;
  --crit:       #C4453F;

  --shadow-sm: 0 1px 2px rgba(46,31,42,.06), 0 1px 3px rgba(196,80,111,.05);
  --shadow-md: 0 2px 4px rgba(46,31,42,.05), 0 8px 24px rgba(196,80,111,.09);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --rail-w: 232px;
  --hour-h: 58px;
}

:root[data-theme="dark"] {
  --paper: #171116;  --surface: #211926;  --surface-2: #2A2030;
  --ink: #F6EDF1;    --ink-2: #D6C4CE;    --muted: #9F8B98;
  --line: #372B36;   --line-2: #2C2230;   --wash: rgba(228,140,165,.06);
  --rose: #E48CA5;   --rose-press: #F0A3B8;
  --rose-soft: #3B2530; --rose-tint: #2A1E27;
  --sand: #D2A87C;   --mulberry: #B78EBE; --teal: #63B49F;
  --amber: #E0AC5A;  --crit: #E4726C;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 8px 28px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Assistant", "Rubik", "Heebo", -apple-system, BlinkMacSystemFont,
               "Segoe UI", "Arial Hebrew", Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

:focus-visible { outline: 2px solid var(--rose); outline-offset: 2px; border-radius: 4px; }

a { color: var(--rose); }

.num, .money {
  font-variant-numeric: tabular-nums;
  direction: ltr; unicode-bidi: isolate; display: inline-block;
}
.money { font-weight: 600; }

.eyebrow { font-size: 11px; letter-spacing: .09em; color: var(--muted); font-weight: 600; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--rail-w) 1fr; min-height: 100vh;
       background: linear-gradient(180deg, var(--wash) 0, transparent 460px); }

.rail {
  background: var(--surface); border-inline-start: 1px solid var(--line);
  padding: 22px 16px; display: flex; flex-direction: column; gap: 26px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding-inline-start: 6px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px; flex: none;
  background: linear-gradient(150deg, var(--rose) 0%, var(--mulberry) 100%);
  display: grid; place-items: center; box-shadow: 0 2px 8px rgba(196,80,111,.35);
}
.brand-name { font-size: 19px; font-weight: 700; }
.brand-sub  { font-size: 11px; color: var(--muted); margin-top: -4px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: 0 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px;
  border-radius: var(--r-sm); color: var(--ink-2); font: inherit;
  font-size: 14.5px; font-weight: 500; text-decoration: none;
  background: none; border: 0; width: 100%; text-align: start; cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 18px; height: 18px; flex: none; opacity: .8; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item[aria-current="page"] { background: var(--rose-soft); color: var(--rose); font-weight: 600; }

.rail-foot { margin-top: auto; }

/* ---------- topbar ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 16px 28px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.page-title { font-size: 20px; font-weight: 700; margin: 0; }
.page-sub   { font-size: 12.5px; color: var(--muted); margin: 0; }
.spacer     { margin-inline-start: auto; }

.search { position: relative; width: min(300px, 32vw); }
.search input {
  width: 100%; font: inherit; font-size: 14px; padding: 9px 14px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); border-radius: 999px;
}

.btn {
  font: inherit; font-size: 14px; font-weight: 600; border-radius: 999px;
  border: 1px solid transparent; padding: 9px 17px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px; text-decoration: none;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn-primary { background: var(--rose); color: #fff; box-shadow: 0 2px 10px rgba(196,80,111,.28); }
.btn-primary:hover { background: var(--rose-press); }
.btn-primary:active { transform: translateY(1px); }
:root[data-theme="dark"] .btn-primary { color: #23161D; }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-sm { padding: 6px 13px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: var(--rose-soft); color: var(--rose);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}

/* ---------- panels & tables ---------- */
.view { padding: 24px 28px 60px; }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm); overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; font-size: 15.5px; font-weight: 700; }

.kpis { display: grid; gap: 14px; grid-template-columns: repeat(4, 1fr); margin-bottom: 22px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 15px 16px 13px; box-shadow: var(--shadow-sm);
}
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -.01em; margin-top: 3px; }
.kpi-foot  { font-size: 12px; color: var(--muted); margin-top: 3px; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; min-width: 620px; }
table.data th {
  text-align: start; font-size: 11.5px; letter-spacing: .06em; color: var(--muted);
  font-weight: 700; padding: 11px 16px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td { padding: 12px 16px; border-bottom: 1px solid var(--line-2); font-size: 14px; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--rose-tint); }
.cell-person { display: flex; align-items: center; gap: 10px; }
.cell-person .name { font-weight: 600; }
.cell-person .sub  { font-size: 12px; color: var(--muted); }

.pill {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px;
  font-weight: 600; padding: 3px 9px; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
}
.pill-ok    { background: color-mix(in srgb, var(--teal) 13%, transparent);  color: var(--teal); }
.pill-wait  { background: color-mix(in srgb, var(--amber) 15%, transparent); color: var(--amber); }
.pill-late,
.pill-failed{ background: color-mix(in srgb, var(--crit) 13%, transparent);  color: var(--crit); }
.pill-draft { background: var(--surface-2); color: var(--muted); border-color: var(--line); }
.pill-rose  { background: var(--rose-soft); color: var(--rose); }

/* ---------- calendar ---------- */
.cal-wrap { display: grid; grid-template-columns: 1fr 296px; gap: 18px; align-items: start; }
.cal-scroll { overflow-x: auto; }
.cal { display: grid; grid-template-columns: 54px repeat(6, minmax(124px, 1fr)); min-width: 720px; }
.cal-corner { border-bottom: 1px solid var(--line); }
.cal-day {
  border-bottom: 1px solid var(--line); border-inline-start: 1px solid var(--line-2);
  padding: 10px 8px 8px; text-align: center;
}
.cal-day .dow  { font-size: 12px; color: var(--muted); font-weight: 600; }
.cal-day .dnum { font-size: 17px; font-weight: 700; margin-top: 1px; }
.cal-day.today .dow  { color: var(--rose); }
.cal-day.today .dnum {
  color: #fff; background: var(--rose); width: 28px; height: 28px; line-height: 28px;
  border-radius: 50%; margin: 1px auto 0; font-size: 14px;
}
:root[data-theme="dark"] .cal-day.today .dnum { color: #23161D; }

.cal-time { height: var(--hour-h); font-size: 11px; color: var(--muted);
            padding-inline-end: 8px; text-align: end; transform: translateY(-7px);
            font-variant-numeric: tabular-nums; }
.cal-col  { position: relative; border-inline-start: 1px solid var(--line-2); }
.cal-col.today { background: var(--rose-tint); }
.cal-slot { height: var(--hour-h); border-bottom: 1px solid var(--line-2); }

.appt {
  position: absolute; inset-inline: 4px; width: calc(100% - 8px);
  border-radius: 7px; padding: 5px 8px 5px 6px;
  background: var(--surface); border: 1px solid var(--line);
  border-inline-start: 3px solid var(--c, var(--rose));
  box-shadow: var(--shadow-sm); overflow: hidden; cursor: pointer;
  text-align: start; font: inherit; display: block;
  transition: transform .12s, box-shadow .12s;
}
.appt:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); z-index: 5; }
.appt .a-time { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.appt .a-name { font-size: 13px; font-weight: 700; color: var(--ink); line-height: 1.25; }
.appt .a-svc  { font-size: 11.5px; color: var(--ink-2); white-space: nowrap;
                overflow: hidden; text-overflow: ellipsis; }

.nowline { position: absolute; inset-inline: 0; height: 0; z-index: 6; pointer-events: none; }
.nowline::before { content: ""; display: block; height: 1.5px; background: var(--rose); opacity: .85; }
.nowline::after  { content: ""; position: absolute; inset-inline-start: -4px; top: -3px;
                   width: 8px; height: 8px; border-radius: 50%; background: var(--rose); }

/* ---------- forms ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 5px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; font: inherit; font-size: 14px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink);
}
.field input:focus, .field select:focus { border-color: var(--rose); }

.alert {
  padding: 10px 14px; border-radius: var(--r-sm); font-size: 13.5px;
  background: color-mix(in srgb, var(--crit) 10%, transparent);
  color: var(--crit); margin-bottom: 14px;
}
.banner {
  background: var(--amber); color: #241800; text-align: center;
  padding: 7px 14px; font-size: 13px; font-weight: 600;
}
.banner form { display: inline; }
.banner button { background: none; border: 0; font: inherit; text-decoration: underline; cursor: pointer; color: inherit; }

/* ---------- auth ---------- */
.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(180deg, var(--wash) 0, transparent 520px), var(--paper);
}
.auth-card {
  width: min(400px, 100%); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 30px 28px; box-shadow: var(--shadow-md);
}
.auth-card h1 { margin: 14px 0 4px; font-size: 22px; }
.auth-card p.lede { margin: 0 0 22px; color: var(--muted); font-size: 13.5px; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .cal-wrap { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .rail {
    position: fixed; inset: auto 0 0 0; height: auto; flex-direction: row;
    align-items: center; gap: 4px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-inline-start: 0; border-top: 1px solid var(--line); z-index: 40;
  }
  .brand, .rail-foot, .nav-label { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; }
  .nav-item { flex-direction: column; gap: 3px; font-size: 11px; padding: 6px 4px;
              min-width: 60px; align-items: center; }
  .nav-item svg { width: 21px; height: 21px; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .search { width: 100%; order: 3; }
  .view { padding: 16px 16px 96px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
