/* ═══════════════════════════════════════════════════════════════════════════════
   OSTIN Planner — Mobile-first Design System
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ── Reset & Tokens ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0f1117;
  --surface:  #1a1d27;
  --surface2: #23273a;
  --border:   #2e3347;
  --accent:   #5b6af0;
  --accent-h: #4a5ae0;
  --peak:     #f59e0b;
  --peak-bg:  rgba(245, 158, 11, .12);
  --std:      #3b82f6;
  --std-bg:   rgba(59, 130, 246, .12);
  --danger:   #ef4444;
  --ok:       #22c55e;
  --text:     #e2e8f0;
  --muted:    #94a3b8;
  --font:     -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --r:        10px;
  --r-lg:     14px;
  --header-h: 48px;
  --bnav-h:   56px;
  --safe-t:   env(safe-area-inset-top, 0px);
  --safe-b:   env(safe-area-inset-bottom, 0px);
}

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

a { color: var(--accent); text-decoration: none; }

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 100dvh;
}

/* ── Header ────────────────────────────────────────────────────────────────── */
.header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; padding-top: var(--safe-t);
  height: calc(var(--header-h) + var(--safe-t));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.header-left  { display: flex; align-items: center; gap: 8px; }
.header-logo  { font-weight: 800; font-size: 16px; letter-spacing: .5px; }
.header-right { display: flex; align-items: center; gap: 10px; }
.header-user  { color: var(--muted); font-size: 13px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-action { color: var(--muted); display: flex; align-items: center; padding: 6px; border-radius: 6px; background: none; border: none; cursor: pointer; font-family: var(--font); -webkit-appearance: none; }
.header-action svg { width: 20px; height: 20px; }
.header-action:active { color: var(--text); background: var(--surface2); }

/* ── Content area ──────────────────────────────────────────────────────────── */
.content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  -webkit-overflow-scrolling: touch;
}

/* ── Bottom Navigation ─────────────────────────────────────────────────────── */
.bnav {
  position: sticky; bottom: 0; z-index: 100;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-b);
  flex-shrink: 0;
}
.bnav-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  padding: 8px 0;
  min-height: var(--bnav-h);
  background: none; border: none;
  color: var(--muted);
  font-family: var(--font);
  cursor: pointer;
  transition: color .15s;
  -webkit-appearance: none;
}
.bnav-item.on  { color: var(--accent); }
.bnav-item:active { color: var(--text); }
.bnav-icon     { display: flex; }
.bnav-icon svg { width: 22px; height: 22px; }
.bnav-label    { font-size: 10px; font-weight: 600; letter-spacing: .3px; }

/* ── View Switcher (segmented control) ─────────────────────────────────────── */
.sched-bar { margin-bottom: 12px; }
.view-switch {
  display: flex;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 3px;
}
.vs-btn {
  flex: 1; padding: 7px 0;
  border: none; background: none;
  color: var(--muted); font-size: 13px; font-weight: 600;
  font-family: var(--font);
  border-radius: calc(var(--r) - 3px);
  cursor: pointer; transition: all .15s;
  -webkit-appearance: none;
}
.vs-btn.on {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}

/* ── Date Navigation ───────────────────────────────────────────────────────── */
.date-nav {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
  user-select: none;
}
.dn-arrow {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; flex-shrink: 0;
  background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--r);
  color: var(--text); cursor: pointer;
  -webkit-appearance: none;
}
.dn-arrow svg { width: 20px; height: 20px; }
.dn-arrow:active { border-color: var(--accent); background: var(--surface); }
.dn-label { flex: 1; text-align: center; }
.dn-title { font-weight: 700; font-size: 15px; }
.dn-badge {
  display: inline-block;
  background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ══════════════════════════════════════════════════════════════════════════════
   DAY VIEW
   ══════════════════════════════════════════════════════════════════════════════ */
.day-list { display: flex; flex-direction: column; gap: 8px; }

.day-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px;
}
.day-card-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.day-card-name { font-weight: 700; font-size: 15px; }
.day-card-meta { font-size: 12px; color: var(--muted); }

.day-shift {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 6px;
}
.day-shift-std  { background: var(--std-bg);  border: 1px solid rgba(59,130,246,.2); }
.day-shift-peak { background: var(--peak-bg); border: 1px solid rgba(245,158,11,.2); }
.day-shift-time { font-weight: 700; font-size: 16px; white-space: nowrap; }
.day-shift-info { flex: 1; display: flex; gap: 8px; align-items: center; }
.day-shift-type { font-size: 12px; color: var(--muted); }
.day-shift-dur  { font-size: 12px; color: var(--muted); }
.day-shift-del {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  background: none; border: none;
  color: var(--muted); cursor: pointer;
  border-radius: 8px; flex-shrink: 0;
  -webkit-appearance: none;
}
.day-shift-del svg { width: 18px; height: 18px; }
.day-shift-del:active { background: rgba(239,68,68,.12); color: var(--danger); }

.day-empty {
  color: var(--muted); font-size: 13px;
  padding: 4px 0 2px;
}

.day-add {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%;
  padding: 10px 0;
  margin-top: 4px;
  background: none;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted); font-size: 13px; font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  -webkit-appearance: none;
  transition: all .15s;
}
.day-add svg { width: 16px; height: 16px; }
.day-add:active { border-color: var(--accent); color: var(--accent); }

/* ══════════════════════════════════════════════════════════════════════════════
   WEEK VIEW
   ══════════════════════════════════════════════════════════════════════════════ */
.week-grid {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.wg-header {
  display: grid;
  grid-template-columns: 64px repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
}
.wg-name-h {
  padding: 8px 6px;
  font-weight: 600; font-size: 11px; color: var(--muted);
  border-right: 1px solid var(--border);
}
.wg-day-h {
  padding: 6px 2px; text-align: center;
  font-size: 11px; font-weight: 600; color: var(--muted);
  border-right: 1px solid var(--border);
  line-height: 1.3;
}
.wg-day-h:last-child { border-right: none; }
.wg-day-num { font-size: 14px; font-weight: 700; color: var(--text); }
.wg-day-h.wg-today { background: rgba(91,106,240,.08); }
.wg-day-h.wg-today .wg-day-num { color: var(--accent); }
.wg-day-h.wg-we .wg-day-num { color: var(--peak); }

.wg-row {
  display: grid;
  grid-template-columns: 64px repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
  min-height: 48px;
}
.wg-row:last-child { border-bottom: none; }

.wg-name {
  padding: 6px; display: flex; align-items: center;
  font-size: 11px; font-weight: 600;
  border-right: 1px solid var(--border);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.wg-cell {
  padding: 4px 2px;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .1s;
  min-height: 48px;
  gap: 2px;
}
.wg-cell:last-child { border-right: none; }
.wg-cell:active     { background: rgba(91,106,240,.12); }
.wg-cell.wg-today   { background: rgba(91,106,240,.06); }

.wg-shift {
  display: block;
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 9px; font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}
.wg-std  { background: var(--std-bg);  color: var(--std); }
.wg-peak { background: var(--peak-bg); color: var(--peak); }

/* ══════════════════════════════════════════════════════════════════════════════
   MONTH VIEW (calendar grid with drag-and-drop)
   ══════════════════════════════════════════════════════════════════════════════ */
.grid-wrap {
  overflow-x: auto; overflow-y: visible;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}
.grid-wrap::-webkit-scrollbar       { height: 6px; }
.grid-wrap::-webkit-scrollbar-track  { background: var(--surface); }
.grid-wrap::-webkit-scrollbar-thumb  { background: var(--border); border-radius: 3px; }

.cal-grid {
  border-collapse: collapse;
  min-width: 100%;
  font-size: 11px;
}
.cal-grid th,
.cal-grid td {
  border: 1px solid var(--border);
  padding: 3px 2px;
  text-align: center;
  vertical-align: top;
  white-space: nowrap;
}

/* Sticky columns */
.gc-sticky {
  position: sticky; left: 0; z-index: 10;
  background: var(--surface);
  min-width: 64px; max-width: 64px;
  text-align: left; padding-left: 6px;
}
thead .gc-sticky { z-index: 20; }

.gc-sticky2 {
  position: sticky; left: 64px; z-index: 10;
  background: var(--surface);
  min-width: 36px; max-width: 36px;
}
thead .gc-sticky2 { z-index: 20; }

.gc-day     { min-width: 50px; }
.gc-dnum    { font-weight: 700; font-size: 12px; }
.gc-dwd     { color: var(--muted); font-size: 10px; }
.gc-today   { background: rgba(91,106,240,.08) !important; }
.gc-we .gc-dnum { color: var(--peak); }

.gc-ename   { font-weight: 600; font-size: 11px; line-height: 1.2; white-space: normal; }
.gc-erate   { color: var(--muted); font-size: 10px; }
.gc-hval    { font-weight: 700; font-size: 11px; display: block; }
.gc-hnorm   { color: var(--muted); font-size: 9px; }
.h-ok       { color: var(--ok); }
.h-low      { color: var(--danger); }

/* Shift chip in grid */
.gc-chip {
  display: block;
  padding: 2px 3px;
  border-radius: 3px;
  font-size: 9px;
  margin-bottom: 2px;
  cursor: pointer;
  line-height: 1.3;
  transition: opacity .15s, transform .1s;
  user-select: none;
}
.gc-chip:active { cursor: grabbing; }
.gc-chip.dragging { opacity: .4; transform: scale(.95); }
.chip-std  { background: var(--std-bg);  color: var(--std);  border: 1px solid var(--std); }
.chip-peak { background: var(--peak-bg); color: var(--peak); border: 1px solid var(--peak); }

.gc-drop.drag-over {
  background: rgba(91,106,240,.18) !important;
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

.gc-add {
  display: none; width: 100%;
  background: none;
  border: 1px dashed var(--border);
  border-radius: 3px;
  color: var(--muted);
  font-size: 11px; padding: 1px 0;
  cursor: pointer; margin-top: 1px;
  -webkit-appearance: none;
}
.gc-day:hover .gc-add { display: block; }
@media (hover: none) { .gc-add { display: block; } }
.gc-add:active { border-color: var(--accent); color: var(--accent); }

/* Drag ghost (touch) */
.drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-family: var(--font);
  opacity: .9;
  transform: translate(-50%, -50%);
}

/* Legend */
.legend {
  display: flex; gap: 14px; flex-wrap: wrap;
  margin-top: 10px;
  font-size: 11px; color: var(--muted);
}
.legend-i { display: flex; align-items: center; gap: 5px; }
.dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 2px;
}
.h-ok-dot { background: var(--ok); }

/* ══════════════════════════════════════════════════════════════════════════════
   SHIFT CARDS (Employee views)
   ══════════════════════════════════════════════════════════════════════════════ */
.shift-list { display: flex; flex-direction: column; gap: 6px; }

.shift-group-title {
  font-size: 11px; font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin: 14px 0 6px;
}
.shift-group-title:first-child { margin-top: 0; }

.shift-card {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 12px;
}
.sc-peak { border-color: rgba(245,158,11,.3); }
.sc-past { opacity: .5; }
.sc-swap { border-color: rgba(59,130,246,.3); }
.sc-left { min-width: 38px; text-align: center; }
.sc-day  { font-weight: 700; font-size: 18px; }
.sc-wd   { color: var(--muted); font-size: 11px; }
.sc-mid  { flex: 1; min-width: 0; }
.sc-time { font-size: 14px; font-weight: 600; }
.sc-type { font-size: 12px; color: var(--muted); margin-top: 1px; }
.sc-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.sc-who  { font-size: 12px; color: var(--muted); }
.sc-meta { display: flex; align-items: center; gap: 4px; margin-top: 2px; flex-wrap: wrap; }
.swap-arrow { color: var(--accent); font-size: 12px; }
.empty-hint { font-size: 12px; margin-top: 6px; opacity: .7; }
.sc-comment { font-size: 12px; color: var(--muted); margin-top: 3px; font-style: italic; line-height: 1.3; }
.sc-pref { font-size: 11px; color: var(--accent); margin-top: 3px; }
.sc-exchange { font-size: 11px; color: var(--success, #22c55e); margin-top: 3px; font-weight: 600; }

/* Date chips for swap creation */
.date-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; max-height: 200px; overflow-y: auto; }
.date-chip { display: inline-flex; }
.date-chip input { display: none; }
.date-chip span {
  display: inline-block; padding: 6px 10px; border-radius: 16px;
  font-size: 13px; background: var(--card); border: 1px solid var(--border);
  cursor: pointer; transition: all .15s;
}
.date-chip input:checked + span {
  background: var(--accent); color: #fff; border-color: var(--accent);
}

/* Shift options for swap accept */
.shift-options { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; max-height: 250px; overflow-y: auto; }
.shift-option { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; background: var(--card); border: 1px solid var(--border); cursor: pointer; }
.shift-option input { accent-color: var(--accent); }
.shift-option span { font-size: 13px; }

/* ══════════════════════════════════════════════════════════════════════════════
   WALLET
   ══════════════════════════════════════════════════════════════════════════════ */
.wallet-bar {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 14px;
  margin-bottom: 14px;
  justify-content: space-around;
  text-align: center;
}
.wallet-item { display: flex; flex-direction: column; gap: 2px; }
.wallet-lbl  { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.wallet-val  { font-size: 20px; font-weight: 700; }
.wallet-val.accent { color: var(--accent); }

.wallet-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}
.wallet-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 14px;
  text-align: center;
}
.wallet-card.wc-accent { border-color: var(--accent); }
.wc-label { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.wc-value { font-size: 30px; font-weight: 800; }
.wc-accent .wc-value { color: var(--accent); }
.wc-hint  { font-size: 11px; color: var(--muted); margin-top: 6px; }

.wallet-history { margin-top: 8px; }
.wh-title { font-size: 16px; font-weight: 700; margin-bottom: 10px; }

/* ══════════════════════════════════════════════════════════════════════════════
   BADGES
   ══════════════════════════════════════════════════════════════════════════════ */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 99px;
  font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.badge-ok   { background: rgba(34,197,94,.12);  color: var(--ok); }
.badge-plan { background: rgba(148,163,184,.12); color: var(--muted); }
.badge-swap   { background: rgba(245,158,11,.12); color: var(--peak); }
.badge-danger { background: rgba(239,68,68,.12); color: var(--danger); }

/* ══════════════════════════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════════════════════════ */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--r);
  padding: 12px 20px;
  font-size: 15px; font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background .15s;
  -webkit-appearance: none;
}
.btn-primary:active { background: var(--accent-h); }
.btn-full { width: 100%; }

.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r);
  padding: 12px 20px;
  font-size: 15px;
  font-family: var(--font);
  cursor: pointer;
  -webkit-appearance: none;
}
.btn-secondary:active { background: var(--surface); }

.btn-danger {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--danger); color: #fff;
  border: none; border-radius: var(--r);
  padding: 12px 20px;
  font-size: 15px; font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  -webkit-appearance: none;
}
.btn-danger:active { opacity: .85; }

.btn-half { flex: 1; }

.btn-sm {
  background: var(--accent); color: #fff;
  border: none; border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px; font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  -webkit-appearance: none;
  white-space: nowrap;
}
.btn-sm svg { width: 14px; height: 14px; vertical-align: -2px; }
.btn-sm:active { background: var(--accent-h); }

.btn-danger-sm {
  background: var(--danger); color: #fff;
  border: none; border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px; font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  -webkit-appearance: none;
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════════════════════
   BOTTOM SHEET
   ══════════════════════════════════════════════════════════════════════════════ */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0);
  display: flex; align-items: flex-end; justify-content: center;
  transition: background .3s;
}
.sheet-overlay.open { background: rgba(0,0,0,.5); }

.sheet {
  width: 100%; max-width: 480px;
  max-height: 85dvh;
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  overflow-y: auto;
  padding-bottom: var(--safe-b);
}
.sheet-overlay.open .sheet { transform: translateY(0); }

.sheet-handle {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 10px auto 6px;
  cursor: grab;
}
.sheet-handle:active { cursor: grabbing; background: var(--muted); }

.sheet-body { padding: 4px 20px 24px; }

.sheet-title   { font-size: 18px; font-weight: 700; margin-bottom: 14px; }
.sheet-text    { font-size: 14px; color: var(--muted); margin-bottom: 16px; line-height: 1.5; }
.sheet-actions { display: flex; gap: 10px; }

/* Sheet form */
.sheet-form { display: flex; flex-direction: column; gap: 14px; margin-bottom: 16px; }
.sf-label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 13px; color: var(--muted);
}
.sf-label input[type="text"],
.sf-label input[type="number"],
.sf-label input[type="datetime-local"],
.sf-label textarea,
.sf-label select,
.sf-label input[type="date"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 11px 12px;
  font-size: 15px;
  width: 100%;
  font-family: var(--font);
  -webkit-appearance: none;
  appearance: none;
}
.sf-label textarea {
  resize: vertical;
  min-height: 60px;
}
.sf-label select:focus,
.sf-label textarea:focus,
.sf-label input:focus {
  outline: none;
  border-color: var(--accent);
}
.sf-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sf-dur { text-align: center; font-size: 13px; color: var(--muted); margin-top: -4px; }

/* ══════════════════════════════════════════════════════════════════════════════
   TASK CARDS
   ══════════════════════════════════════════════════════════════════════════════ */
.task-list { display: flex; flex-direction: column; gap: 6px; }

.task-card {
  display: flex; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px;
}
.task-main { flex: 1; min-width: 0; }
.task-title { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.task-desc { font-size: 13px; color: var(--muted); margin-bottom: 6px; line-height: 1.4; }
.task-meta {
  display: flex; flex-wrap: wrap; gap: 8px;
  font-size: 12px; color: var(--muted);
}
.task-reward { color: var(--peak); font-weight: 600; }
.task-deadline { color: var(--muted); }
.task-assignee { color: var(--muted); }
.task-reject-msg {
  margin-top: 6px;
  font-size: 12px;
  color: var(--danger);
  background: rgba(239,68,68,.08);
  padding: 6px 8px;
  border-radius: 6px;
}
.task-side {
  display: flex; flex-direction: column;
  align-items: flex-end; justify-content: space-between;
  flex-shrink: 0; gap: 8px;
}
.task-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.task-dir-actions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.btn-xs {
  font-size: 11px; padding: 3px 7px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--card);
  color: var(--text); cursor: pointer;
}
.btn-ok-xs { border-color: rgba(34,197,94,.4); color: var(--success, #22c55e); }
.btn-danger-xs { border-color: rgba(239,68,68,.4); color: var(--danger); }
.btn-muted-xs { opacity: .6; }
.task-card.task-overdue { border-color: rgba(239,68,68,.4); }
.task-card.task-failed { border-color: rgba(239,68,68,.3); opacity: .7; }
.sheet-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.task-deadline.overdue { color: var(--danger); font-weight: 600; }
.task-completion-msg {
  margin-top: 6px; font-size: 12px; color: var(--muted);
  background: rgba(91,106,240,.06); padding: 6px 8px; border-radius: 6px;
}
.task-photos { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.task-photo {
  width: 52px; height: 52px; object-fit: cover;
  border-radius: 6px; border: 1px solid var(--border); cursor: pointer;
}
.task-photos-review { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.task-photo-lg {
  width: 100px; height: 100px; object-fit: cover;
  border-radius: 8px; border: 1px solid var(--border); cursor: pointer;
}
.review-task-title { font-weight: 600; font-size: 15px; margin-bottom: 10px; }

/* Photo upload */
.photo-upload-area { margin-top: 4px; }
.photo-grid { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.photo-thumb {
  position: relative; width: 64px; height: 64px;
  border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-rm {
  position: absolute; top: 2px; right: 2px;
  width: 20px; height: 20px;
  background: rgba(0,0,0,.7); color: #fff;
  border: none; border-radius: 50%;
  font-size: 14px; line-height: 20px; text-align: center;
  cursor: pointer; -webkit-appearance: none;
}
.photo-btns { display: flex; gap: 8px; }
.btn-photo-lbl {
  display: inline-flex; align-items: center; gap: 4px;
  cursor: pointer;
}

/* Deadline quick buttons */
.deadline-quick { display: flex; gap: 6px; margin-top: 6px; }
.dq-btn {
  flex: 1; padding: 6px 4px;
  background: var(--surface2); color: var(--muted);
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 11px; font-weight: 600;
  font-family: var(--font); cursor: pointer;
  -webkit-appearance: none; text-align: center;
}
.dq-btn:active { border-color: var(--accent); color: var(--accent); }

/* Screen header (title + action button) */
.screen-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.screen-header .screen-title { margin-bottom: 0; }

/* ══════════════════════════════════════════════════════════════════════════════
   SCREEN TITLE
   ══════════════════════════════════════════════════════════════════════════════ */
.screen-title {
  font-size: 18px; font-weight: 700;
  margin-bottom: 14px;
}

/* ══════════════════════════════════════════════════════════════════════════════
   TOAST
   ══════════════════════════════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: calc(var(--bnav-h) + var(--safe-b) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 22px;
  border-radius: 10px;
  font-size: 14px; font-weight: 600;
  z-index: 10000;
  opacity: 0;
  transition: opacity .3s, transform .3s;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast-ok  { background: var(--ok);     color: #000; }
.toast-err { background: var(--danger); color: #fff; }

/* ══════════════════════════════════════════════════════════════════════════════
   LOADING & EMPTY STATES
   ══════════════════════════════════════════════════════════════════════════════ */
.loading {
  display: flex; align-items: center; justify-content: center;
  min-height: 200px;
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid rgba(255,255,255,.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.empty-icon { margin-bottom: 12px; }
.empty-icon svg { width: 48px; height: 48px; color: var(--border); }
.empty-state p { font-size: 14px; line-height: 1.6; }

/* ══════════════════════════════════════════════════════════════════════════════
   LOGIN
   ══════════════════════════════════════════════════════════════════════════════ */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 28px;
  width: min(380px, 90vw);
  text-align: center;
}
.login-logo {
  font-size: 32px; font-weight: 900;
  letter-spacing: 2px;
  margin-bottom: 6px;
}
.login-sub  { color: var(--muted); margin-bottom: 28px; font-size: 14px; }
.login-hint { color: var(--muted); font-size: 14px; line-height: 1.7; }

/* ══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════════════════════ */
@media (min-width: 768px) {
  .content { padding: 16px 24px; }
  .day-list { max-width: 640px; }
  .wallet-cards { max-width: 400px; }

  .sheet {
    max-width: 480px;
    border-radius: var(--r-lg);
    margin-bottom: 10vh;
  }
}

/* ── Telegram WebApp theme adaptation ──────────────────────────────────────── */
@supports (color: var(--tg-theme-bg-color)) {
  body.tg-theme {
    --bg: var(--tg-theme-bg-color);
    --surface: var(--tg-theme-secondary-bg-color);
    --text: var(--tg-theme-text-color);
    --accent: var(--tg-theme-button-color, var(--accent));
  }
}
