:root {
  color-scheme: dark;
  --bg: #090d12;
  --bg-2: #101820;
  --panel: rgba(22, 30, 39, 0.78);
  --panel-solid: #151d26;
  --line: rgba(255,255,255,0.11);
  --text: #eef5f7;
  --muted: #98a8b4;
  --accent: #45d6a3;
  --accent-2: #62a8ff;
  --warn: #ffbf5f;
  --danger: #ff6b6b;
  --ok: #44d07b;
  --shadow: 0 18px 60px rgba(0,0,0,.32);
  --radius: 18px;
}

body.light {
  color-scheme: light;
  --bg: #f5f7fa;
  --bg-2: #eef2f6;
  --panel: rgba(255,255,255,0.82);
  --panel-solid: #ffffff;
  --line: rgba(20, 35, 55, 0.12);
  --text: #15202b;
  --muted: #657282;
  --accent: #14936e;
  --accent-2: #226ed8;
  --shadow: 0 18px 52px rgba(30,45,65,.12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 15% 10%, rgba(69,214,163,.18), transparent 30%),
    radial-gradient(circle at 90% 0%, rgba(98,168,255,.16), transparent 28%),
    linear-gradient(145deg, var(--bg), var(--bg-2));
  color: var(--text);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: rgba(9, 13, 18, .58);
  backdrop-filter: blur(22px);
}
body.light .sidebar { background: rgba(255,255,255,.58); }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.brand-mark {
  width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #061016; font-weight: 900;
}
.brand span, .eyebrow, .muted { color: var(--muted); }
.brand span { display: block; font-size: 12px; margin-top: 2px; }
.nav { display: grid; gap: 7px; }
.nav-btn {
  width: 100%; border: 0; color: var(--muted); background: transparent; padding: 11px 12px;
  border-radius: 14px; display: flex; align-items: center; gap: 10px; text-align: left;
  transition: .18s ease;
}
.nav-btn:hover, .nav-btn.active { color: var(--text); background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); }
.nav-ico { width: 23px; text-align: center; }
.main { padding: 24px 28px 88px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.topbar h1 { margin: 0; font-size: clamp(28px, 4vw, 42px); letter-spacing: 0; }
.eyebrow { margin: 0 0 4px; font-size: 13px; text-transform: uppercase; }
.theme-toggle, .btn, .ghost-btn, .danger-btn, .icon-btn {
  border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; color: var(--text);
  background: var(--panel); box-shadow: 0 10px 30px rgba(0,0,0,.12);
}
.icon-btn { width: 42px; height: 42px; padding: 0; display: grid; place-items: center; }
.btn { border: 0; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #061016; font-weight: 800; }
.ghost-btn { background: transparent; }
.danger-btn { border-color: rgba(255,107,107,.35); color: var(--danger); background: rgba(255,107,107,.09); }
.btn:hover, .ghost-btn:hover, .danger-btn:hover, .theme-toggle:hover, .icon-btn:hover { transform: translateY(-1px); }
.view { display: none; animation: lift .24s ease both; }
.view.active { display: block; }
@keyframes lift { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); backdrop-filter: blur(18px);
}
.card.compact { padding: 14px; }
.card h2, .card h3 { margin: 0 0 12px; }
.hero-card { display: grid; grid-template-columns: 1.1fr .9fr; gap: 18px; align-items: center; }
.big-number { font-size: clamp(38px, 8vw, 72px); line-height: 1; font-weight: 900; margin: 10px 0; }
.stat { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.035); }
.stat strong { font-size: 22px; }
.progress { height: 12px; background: rgba(255,255,255,.09); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: inherit; transition: width .35s ease; }
.macro-list { display: grid; gap: 12px; }
.quick-actions { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.quick-actions button { min-height: 58px; }
.bars { display: flex; align-items: end; gap: 9px; height: 170px; padding-top: 14px; }
.bar-wrap { flex: 1; min-width: 0; display: grid; gap: 6px; text-align: center; color: var(--muted); font-size: 11px; }
.bar { height: 120px; display: flex; align-items: end; background: rgba(255,255,255,.06); border-radius: 999px; overflow: hidden; }
.bar span { width: 100%; min-height: 4px; background: linear-gradient(180deg, var(--accent-2), var(--accent)); border-radius: inherit; }
.mini-cal, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.day, .weekday {
  min-height: 78px; border: 1px solid var(--line); border-radius: 14px; padding: 8px; background: rgba(255,255,255,.035);
}
.weekday { min-height: auto; text-align: center; color: var(--muted); background: transparent; border: 0; }
.day { text-align: left; color: var(--text); }
.day.empty { opacity: .35; }
.day.low { border-color: rgba(98,168,255,.35); }
.day.near { border-color: rgba(69,214,163,.55); background: rgba(69,214,163,.09); }
.day.high { border-color: rgba(255,191,95,.55); background: rgba(255,191,95,.1); }
.day small { display: block; color: var(--muted); margin-top: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
label { color: var(--muted); font-size: 13px; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); color: var(--text); background: rgba(255,255,255,.055);
  border-radius: 13px; padding: 11px 12px; outline: none;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(69,214,163,.15); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }
.list { display: grid; gap: 10px; }
.list-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.035); }
.pill { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 5px 9px; font-size: 12px; }
.filters { display: grid; grid-template-columns: 1.3fr repeat(3, minmax(150px, .7fr)); gap: 10px; margin-bottom: 14px; }
.catalog { display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 14px; }
.catalog-card { min-height: 230px; display: flex; flex-direction: column; justify-content: space-between; transition: .18s ease; }
.catalog-card:hover { transform: translateY(-3px); border-color: rgba(69,214,163,.45); }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.photo-preview { width: 100%; min-height: 260px; border: 1px dashed var(--line); border-radius: 18px; display: grid; place-items: center; overflow: hidden; background: rgba(255,255,255,.035); }
.photo-preview img { width: 100%; height: 100%; max-height: 360px; object-fit: cover; display: block; }
.notice { border-left: 4px solid var(--accent-2); padding: 12px 14px; border-radius: 12px; background: rgba(98,168,255,.09); color: var(--text); }
.loader { display: inline-block; width: 18px; height: 18px; border: 3px solid rgba(255,255,255,.24); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.camera-box { min-height: 220px; display: grid; place-items: center; border: 1px dashed var(--line); border-radius: 18px; overflow: hidden; }
video { width: 100%; max-height: 320px; object-fit: cover; }
.modal-root { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; background: rgba(0,0,0,.56); padding: 18px; }
.modal-root[hidden] { display: none; }
.modal { width: min(760px, 100%); max-height: 88vh; overflow: auto; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 20px; padding: 18px; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.toast-stack { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 10px; }
.toast { padding: 12px 14px; border-radius: 14px; background: var(--panel-solid); border: 1px solid var(--line); box-shadow: var(--shadow); max-width: 330px; }
.bottom-nav, .mobile-drawer, .mobile-only { display: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.empty { padding: 24px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 16px; }
.two-pane { display: grid; grid-template-columns: 1fr 360px; gap: 16px; }
.danger-zone { border-color: rgba(255,107,107,.35); }

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 14px 12px 96px; }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    margin: -14px -12px 16px;
    padding: 14px 12px 12px;
    background: rgba(9, 13, 18, .76);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(18px);
  }
  body.light .topbar { background: rgba(245,247,250,.82); }
  .mobile-only { display: grid; }
  .bottom-nav {
    position: fixed; left: 10px; right: 10px; bottom: 10px; z-index: 50; display: grid;
    grid-template-columns: repeat(5, 1fr); gap: 6px; padding: 8px; background: var(--panel-solid);
    border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow);
  }
  .bottom-nav .nav-btn { justify-content: center; padding: 9px 4px; font-size: 11px; flex-direction: column; gap: 2px; border-radius: 13px; }
  .bottom-nav .nav-btn span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-drawer { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.52); padding: 14px; }
  .mobile-drawer.open { display: block; }
  .drawer-panel { width: min(340px, 92vw); height: 100%; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 20px; padding: 16px; box-shadow: var(--shadow); overflow: auto; }
  .hero-card, .two-pane { grid-template-columns: 1fr; }
  .grid.cols-3, .grid.cols-4, .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 680px) {
  .topbar { align-items: flex-start; }
  .topbar h1 { font-size: 26px; }
  .eyebrow { font-size: 11px; }
  .theme-toggle { padding: 9px 10px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .form-grid, .filters { grid-template-columns: 1fr; }
  .quick-actions { grid-template-columns: 1fr 1fr; }
  .quick-actions button { min-height: 52px; }
  .card { padding: 14px; border-radius: 16px; }
  .hero-card { gap: 14px; }
  .big-number { font-size: 42px; }
  .stat strong { font-size: 18px; }
  .day { min-height: 64px; padding: 6px; font-size: 12px; }
  .day small { font-size: 10px; }
  .list-row { grid-template-columns: 1fr; }
  .bars { gap: 5px; }
}
