:root {
  --bg: #f6f2eb;
  --outer: #e5dfd5;
  --card: #ffffff;
  --ink: #272522;
  --muted: #7f7a72;
  --line: #eae4da;
  --brand: #5a8566;
  --brand-dark: #497054;
  --brand-soft: #ecf4ee;
  --teal: #3f7e85;
  --teal-soft: #e9f4f5;
  --ok: #3f8254;
  --ok-soft: #e4f3e8;
  --warn: #c47222;
  --warn-soft: #fcf0e1;
  --bad: #bf4b4b;
  --bad-soft: #fae6e6;
  --purple: #7a58b8;
  --purple-soft: #f2ecfa;
  --radius: 18px;
  --shadow: 0 2px 6px rgba(64,52,36,.05), 0 8px 22px rgba(64,52,36,.04);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  background: linear-gradient(160deg, #eae3d8 0%, #dcd4c6 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 14px; line-height: 1.45;
  min-height: 100dvh;
}
.app-shell {
  max-width: 520px; margin: 0 auto; min-height: 100dvh;
  background:
    radial-gradient(circle at 92% 8%, rgba(143,184,154,.18), transparent 34%),
    radial-gradient(circle at 6% 42%, rgba(232,188,142,.14), transparent 36%),
    var(--bg);
  display: flex; flex-direction: column;
  padding-bottom: 86px;
  box-shadow: 0 0 42px rgba(45,38,28,.1);
}
header.topbar {
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(135deg, #567f62 0%, #749c7e 100%);
  color: #fff;
  padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  box-shadow: 0 3px 14px rgba(63,97,73,.18);
}
.brand-box { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 11px; flex-shrink: 0;
  background: rgba(255,255,255,.22); border: 1px solid rgba(255,255,255,.28);
  color: #fff; font-weight: 800; font-size: 14px;
  display: grid; place-items: center;
}
.brand-title { font-weight: 700; font-size: 15.5px; letter-spacing: .01em; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 11px; color: rgba(255,255,255,.88); display: flex; align-items: center; gap: 5px; }
.dot { width: 7px; height: 7px; border-radius: 99px; display: inline-block; }
.dot.local { background: #fde68a; }
.dot.cloud { background: #86efac; }

.top-right { display: flex; align-items: center; gap: 6px; }
.role-select {
  border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.18); color: #fff;
  border-radius: 10px; padding: 6px 8px; font-size: 12px; font-weight: 600;
  max-width: 148px;
}
.role-select option { color: var(--ink); background: #fff; }
.icon-btn {
  border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.18); color: #fff;
  border-radius: 10px; width: 34px; height: 32px; display: grid; place-items: center;
  cursor: pointer; font-size: 15px;
}

main { padding: 14px; display: flex; flex-direction: column; gap: 12px; flex: 1; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
}
.card.soft-warn { background: linear-gradient(135deg, #fff8ee, #fdf0de); border-color: #f2d5af; }
.card.soft-brand { background: linear-gradient(135deg, #f1f7f2, #e7f1ea); border-color: #cde0d2; }
.card.soft-teal { background: linear-gradient(135deg, #eff7f7, #e4f2f3); border-color: #c4dfe1; }

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-title { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 6px; color: var(--ink); }
.muted { color: var(--muted); font-size: 12.5px; }
.tiny { font-size: 11.5px; color: var(--muted); }

.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.kpi-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.kpi {
  background: #faf7f2; border: 1px solid var(--line); border-radius: 13px; padding: 10px 12px;
}
.kpi .lbl { font-size: 11px; color: var(--muted); font-weight: 600; }
.kpi .val { font-size: 18px; font-weight: 800; margin-top: 2px; letter-spacing: -.02em; color: var(--ink); }
.kpi .sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row-wrap { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  border: 1px solid var(--line); border-radius: 14px; padding: 11px 13px;
  background: #fff; display: flex; flex-direction: column; gap: 8px;
  box-shadow: 0 1px 3px rgba(64,52,36,.03);
}
.item.clickable { cursor: pointer; transition: border-color .15s, transform .1s, background .15s; }
.item.clickable:hover { border-color: #c5d8ca; background: #fcfbf8; }
.item.done-item { background: #faf8f4; opacity: .88; }
.item.pending-item { background: #fff9f0; border-color: #f0ce9e; }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 99px;
  white-space: nowrap;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.brand { background: var(--brand-soft); color: var(--brand); }
.pill.teal { background: var(--teal-soft); color: var(--teal); }
.pill.purple { background: var(--purple-soft); color: var(--purple); }
.pill.gray { background: #f0ece5; color: #6e6961; }

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 11px; padding: 8px 12px; font-size: 12px; font-weight: 700;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  transition: transform .08s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ok { background: #4c8c5e; border-color: #4c8c5e; color: #fff; }
.btn.warn { background: #d4822e; border-color: #d4822e; color: #fff; }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--brand); }
.btn.sm { padding: 5px 10px; font-size: 11.5px; border-radius: 9px; }
.btn.block { width: 100%; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 99px; padding: 6px 12px; font-size: 12px; font-weight: 600;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
}
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.search-bar { display: flex; gap: 8px; align-items: center; }
input[type="text"], input[type="number"], input[type="date"], input[type="time"], input[type="tel"], input[type="month"], select, textarea {
  width: 100%; border: 1px solid #e2dbd0; border-radius: 11px;
  padding: 9px 11px; font-size: 13px; color: var(--ink); background: #fff;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #b9d4c0; border-color: var(--brand); }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field label { font-size: 12px; font-weight: 700; color: #47433d; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.bar-track { height: 8px; border-radius: 99px; background: #eae3d8; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; background: var(--brand); transition: width .3s; }
.bar-fill.ok { background: #5a8f69; }
.bar-fill.warn { background: #d9822b; }
.bar-fill.bad { background: #c45050; }

nav.bottom {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 520px; z-index: 35;
  background: rgba(255,255,255,.95); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.nav-btn {
  border: none; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 5px 2px; border-radius: 10px; cursor: pointer; position: relative;
  font-size: 11px; font-weight: 600;
}
.nav-btn .ico { font-size: 18px; line-height: 1; opacity: .75; }
.nav-btn.active { color: var(--brand); font-weight: 800; }
.nav-btn.active .ico { opacity: 1; }
.nav-badge {
  position: absolute; top: 1px; right: calc(50% - 20px);
  background: var(--bad); color: #fff; font-size: 10px; font-weight: 800;
  min-width: 17px; height: 17px; border-radius: 99px; padding: 0 4px;
  display: grid; place-items: center;
}

.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(39,34,27,.45); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-sheet {
  width: 100%; max-width: 520px; max-height: 90dvh; overflow-y: auto;
  background: #fdfbf8; border-radius: 24px 24px 0 0; padding: 16px 16px 24px;
  box-shadow: 0 -10px 35px rgba(39,34,27,.2);
}
.sheet-handle { width: 40px; height: 4px; border-radius: 99px; background: #d6cec2; margin: 0 auto 12px; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 6px; }
.cal-cell {
  aspect-ratio: 1; border-radius: 9px; display: grid; place-items: center;
  font-size: 11px; font-weight: 600; background: #f6f2eb; color: var(--muted);
}
.cal-cell.hdr { background: transparent; font-size: 10px; aspect-ratio: auto; padding: 2px 0; }
.cal-cell.hit { background: var(--brand); color: #fff; font-weight: 800; }
.cal-cell.late { background: #d9822b; color: #fff; font-weight: 800; }

.chart-bars { display: flex; align-items: flex-end; gap: 5px; height: 120px; padding-top: 12px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.chart-pair { display: flex; align-items: flex-end; gap: 2px; width: 100%; height: 90px; justify-content: center; }
.bar-v { width: 42%; border-radius: 5px 5px 0 0; min-height: 2px; }
.bar-v.cur { background: linear-gradient(180deg, #5a8566, #83ab8d); }
.bar-v.prev { background: #dcd4c7; }
.chart-lbl { font-size: 10px; color: var(--muted); font-weight: 600; }

.toast {
  position: fixed; bottom: 86px; left: 50%; transform: translateX(-50%);
  background: #35473a; color: #fff; padding: 10px 16px; border-radius: 13px;
  font-size: 12.5px; font-weight: 600; z-index: 90; box-shadow: 0 8px 24px rgba(0,0,0,.22);
  max-width: 92vw; text-align: center;
}
.divider { height: 1px; background: var(--line); margin: 10px 0; }
.empty { text-align: center; padding: 24px 12px; color: var(--muted); font-size: 13px; }
details summary { cursor: pointer; font-weight: 700; font-size: 12.5px; color: var(--muted); list-style: none; }
details summary::-webkit-details-marker { display: none; }

.pkg-details { background: #fff; border: 1px solid #d4e3d8; border-radius: 13px; padding: 10px 11px; }
.pkg-details > summary { color: var(--brand); font-size: 12.5px; }
.pkg-old { padding: 11px 12px; }
.slot-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.slot-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 9px; border-radius: 10px; background: #faf7f2; border: 1px solid var(--line);
}
.slot-row.empty-slot { background: #fff; border-style: dashed; opacity: .9; }
.slot-num {
  width: 24px; height: 24px; border-radius: 99px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 11px; font-weight: 800;
  background: #e9e3d9; color: #6e6961;
}
.slot-num.done { background: var(--brand); color: #fff; }
