@layer reset, base, components, screens, themes;

@layer reset {
  * { box-sizing: border-box; }
  html, body { margin: 0; min-height: 100%; }
  body { min-height: 100dvh; }
  button, input, select, textarea { font: inherit; }
  button { cursor: pointer; }
  button:disabled { cursor: not-allowed; opacity: .55; }
}

@layer base {
  :root {
    --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --bottom-nav-h: 82px;
    --radius-card: 26px;
    --radius-soft: 18px;
    --duration-page: 360ms;
    --ease-premium: cubic-bezier(.2,.85,.25,1);
    --bg: #071426;
    --bg-soft: #0b1f3a;
    --surface: rgba(255,255,255,.08);
    --surface-strong: rgba(255,255,255,.13);
    --stroke: rgba(255,255,255,.14);
    --text: #f8fafc;
    --muted: rgba(248,250,252,.66);
    --accent: #38bdf8;
    --accent-2: #60a5fa;
    --danger: #fb7185;
    --success: #34d399;
    --warning: #fbbf24;
    --icon-color: rgba(248,250,252,.82);
    --icon-active: #ffffff;
    --icon-accent: var(--accent);
    --icon-glow: rgba(56,189,248,.28);
    --badge-a: var(--accent);
    --badge-b: var(--accent-2);
  }

  body {
    font-family: var(--font-ui);
    color: var(--text);
    background:
      radial-gradient(circle at 20% 0%, rgba(56,189,248,.22), transparent 30%),
      linear-gradient(180deg, var(--bg), #020617 72%);
    overflow: hidden;
  }

  .app-shell { min-height: 100dvh; display: grid; grid-template-rows: 1fr auto; }
  .screen-root { min-height: 0; overflow-y: auto; padding: 18px 16px calc(var(--bottom-nav-h) + env(safe-area-inset-bottom) + 18px); }
  .screen { max-width: 780px; margin: 0 auto; animation: pageSlideIn var(--duration-page) var(--ease-premium); }
  @keyframes pageSlideIn { from { opacity: 0; transform: translate3d(16px, 0, 0); } to { opacity: 1; transform: translate3d(0, 0, 0); } }
  @media (prefers-reduced-motion: reduce) { .screen { animation: none; } }
}

@layer components {
  .hero { margin: 12px 0 22px; }
  .hero-kicker { color: var(--accent); font-size: .78rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
  .hero-title { margin: 6px 0 0; font-size: clamp(2.2rem, 9vw, 4rem); line-height: .94; letter-spacing: -.08em; font-weight: 950; text-align: center; }
  .hero-subtitle { margin: 10px auto 0; max-width: 35rem; color: var(--muted); font-weight: 760; line-height: 1.35; text-align: center; }

  .card { border: 1px solid var(--stroke); border-radius: var(--radius-card); background: linear-gradient(145deg, var(--surface-strong), var(--surface)); box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 20px 70px rgba(0,0,0,.22); }
  .stack { display: grid; gap: 14px; }
  .grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  @media (max-width: 420px) { .grid-3 { grid-template-columns: 1fr; } }

  .btn { border: 1px solid var(--stroke); border-radius: 20px; min-height: 52px; padding: 12px 14px; color: var(--text); background: var(--surface); font-weight: 900; display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
  .btn-primary { border: 0; background: linear-gradient(135deg, var(--badge-a), var(--badge-b)); box-shadow: 0 18px 46px var(--icon-glow); }
  .btn-danger { color: #fecdd3; border-color: rgba(251,113,133,.3); background: rgba(251,113,133,.12); }
  .btn-success { color: #bbf7d0; border-color: rgba(52,211,153,.3); background: rgba(52,211,153,.12); }

  .field { display: grid; gap: 8px; color: var(--muted); font-weight: 850; }
  .input, .select, .textarea { width: 100%; min-height: 50px; border: 1px solid var(--stroke); border-radius: 18px; color: var(--text); background: rgba(255,255,255,.07); padding: 12px 14px; outline: none; }
  .textarea { min-height: 120px; resize: vertical; line-height: 1.45; }

  .icon { width: 26px; height: 26px; color: currentColor; display: inline-block; }
  .icon svg { width: 100%; height: 100%; display: block; }

  .bottom-nav { position: fixed; left: 12px; right: 12px; bottom: calc(8px + env(safe-area-inset-bottom)); height: var(--bottom-nav-h); border: 1px solid var(--stroke); border-radius: 28px; background: rgba(4,12,28,.84); backdrop-filter: blur(20px); display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; gap: 4px; padding: 8px; box-shadow: 0 -18px 60px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.08); z-index: 20; }
  .nav-button { min-width: 0; border: 0; border-radius: 20px; height: 100%; background: transparent; color: var(--icon-color); display: grid; place-items: center; gap: 2px; font-size: .68rem; font-weight: 900; }
  .nav-button .icon { width: 31px; height: 31px; filter: drop-shadow(0 0 10px var(--icon-glow)); }
  .nav-button.is-active { color: var(--icon-active); background: rgba(255,255,255,.1); }
  .nav-button.is-home { transform: translateY(-7px); border-radius: 24px; background: linear-gradient(135deg, var(--badge-a), var(--badge-b)); color: #fff; box-shadow: 0 18px 50px var(--icon-glow); }

  .weekbar { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 8px; margin: 16px 0 18px; }
  .day-cell { min-height: 74px; border: 1px solid var(--stroke); border-radius: 22px; background: var(--surface); color: var(--text); display: grid; place-items: center; padding: 8px 4px; transition: transform var(--duration-page) var(--ease-premium), border-color var(--duration-page) var(--ease-premium), background var(--duration-page) var(--ease-premium); }
  .day-cell:active { transform: scale(.97); }
  .day-cell.is-today { border-color: color-mix(in srgb, var(--accent), white 25%); }
  .day-cell.is-selected { background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 24%, transparent), var(--surface)); box-shadow: 0 16px 36px var(--icon-glow); }
  .day-name { font-size: .72rem; color: var(--muted); font-weight: 900; text-transform: uppercase; }
  .day-num { font-size: 1.24rem; font-weight: 950; }
  .status-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--muted); }
  .status-dot.work { background: var(--success); } .status-dot.rest { background: var(--muted); } .status-dot.weather { background: var(--accent); } .status-dot.absent { background: var(--danger); }

  .toast-host { position: fixed; left: 14px; right: 14px; bottom: calc(var(--bottom-nav-h) + 22px + env(safe-area-inset-bottom)); display: grid; gap: 8px; z-index: 40; pointer-events: none; }
  .toast { justify-self: center; max-width: 92vw; padding: 12px 14px; border-radius: 18px; color: var(--text); background: rgba(15,23,42,.94); border: 1px solid var(--stroke); box-shadow: 0 18px 50px rgba(0,0,0,.28); font-weight: 850; pointer-events: auto; }
  .field-card { padding: 16px; }
}

@layer screens {
  .clock-card { padding: 26px; text-align: center; }
  .clock-time { font-size: clamp(3.2rem, 16vw, 7rem); line-height: .9; font-weight: 950; letter-spacing: -.08em; }
  .clock-date { color: var(--muted); font-weight: 850; margin-top: 8px; }
  .badge-button { width: min(260px, 78vw); aspect-ratio: 1; border: 0; border-radius: 999px; margin: 22px auto; color: white; background: linear-gradient(135deg, var(--badge-a), var(--badge-b)); box-shadow: 0 26px 80px var(--icon-glow), inset 0 1px 0 rgba(255,255,255,.18); display: grid; place-items: center; font-size: 1.28rem; font-weight: 950; letter-spacing: -.02em; }
  .kpi { padding: 16px; min-height: 96px; display: grid; align-content: center; gap: 6px; }
  .kpi small { color: var(--muted); font-weight: 850; } .kpi strong { font-size: 1.45rem; letter-spacing: -.04em; }
  .section-title { margin: 20px 0 10px; font-size: 1.25rem; letter-spacing: -.04em; }
  .action-list { display: grid; gap: 10px; }
  .action-card { width: 100%; justify-content: flex-start; min-height: 68px; }
  .meal-separator { margin: 18px 0 12px; color: var(--muted); font-size: .78rem; font-weight: 950; letter-spacing: .1em; text-transform: uppercase; text-align: center; }
}

@layer themes {
  body[data-theme="navy"] { --bg: #10223f; --bg-soft: #143154; --accent: #4cc9f0; --accent-2: #4361ee; --badge-a: #4cc9f0; --badge-b: #4361ee; --icon-glow: rgba(76,201,240,.28); }
  body[data-theme="space"] { --bg: #080b22; --bg-soft: #11173d; --accent: #a78bfa; --accent-2: #38bdf8; --badge-a: #a78bfa; --badge-b: #38bdf8; --icon-glow: rgba(167,139,250,.34); }
  body[data-theme="nova"] { --bg: #16001f; --bg-soft: #29063e; --accent: #ff2bd6; --accent-2: #00f5ff; --badge-a: #ff2bd6; --badge-b: #00f5ff; --icon-glow: rgba(255,43,214,.32); }
  body[data-theme="forest"] { --bg: #0b2017; --bg-soft: #123326; --accent: #34d399; --accent-2: #84cc16; --badge-a: #22c55e; --badge-b: #84cc16; --icon-glow: rgba(52,211,153,.28); }
  body[data-theme="sunset"] { --bg: #fff7ed; --bg-soft: #ffedd5; --surface: rgba(15,23,42,.05); --surface-strong: rgba(15,23,42,.08); --stroke: rgba(15,23,42,.12); --text: #1f2937; --muted: rgba(31,41,55,.65); --accent: #f97316; --accent-2: #fb7185; --badge-a: #f97316; --badge-b: #fb7185; --icon-color: rgba(31,41,55,.72); --icon-active: #111827; --icon-glow: rgba(249,115,22,.22); }
}

@layer components {
  .nav-sheet-host {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--bottom-nav-h) + 18px + env(safe-area-inset-bottom));
    z-index: 19;
    pointer-events: none;
  }
  .nav-sheet {
    width: min(420px, calc(100vw - 24px));
    margin: 0 auto;
    border: 1px solid var(--stroke);
    border-radius: 26px;
    background: linear-gradient(145deg, var(--surface-strong), var(--surface));
    backdrop-filter: blur(22px);
    box-shadow: 0 22px 70px rgba(0,0,0,.34), inset 0 1px 0 rgba(255,255,255,.1);
    padding: 10px;
    display: grid;
    gap: 8px;
    pointer-events: auto;
    animation: navSheetIn 240ms var(--ease-premium);
  }
  .nav-sheet-button {
    min-height: 52px;
    border: 1px solid var(--stroke);
    border-radius: 18px;
    background: rgba(255,255,255,.07);
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    font-weight: 920;
    text-align: left;
  }
  .nav-sheet-button .icon {
    width: 28px;
    height: 28px;
    color: var(--icon-active);
    filter: drop-shadow(0 0 10px var(--icon-glow));
    flex: 0 0 28px;
  }
  @keyframes navSheetIn {
    from { opacity: 0; transform: translate3d(0, 12px, 0) scale(.98); }
    to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
  }
  .toast {
    animation: toastAutoDismiss 4.2s var(--ease-premium) forwards;
  }
  @keyframes toastAutoDismiss {
    0% { opacity: 0; transform: translate3d(0, 10px, 0) scale(.98); }
    12% { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
    82% { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
    100% { opacity: 0; transform: translate3d(0, 8px, 0) scale(.98); }
  }
  @media (prefers-reduced-motion: reduce) {
    .nav-sheet { animation: none; }
  }
}

@layer components {
  .company-hero { text-align: center; }
  .company-logo {
    width: 76px;
    height: 76px;
    border-radius: 26px;
    display: grid;
    place-items: center;
    margin: 0 auto 14px;
    border: 1px solid var(--stroke);
    background: linear-gradient(135deg, var(--badge-a), var(--badge-b));
    color: #fff;
    font-size: 1.35rem;
    font-weight: 950;
    letter-spacing: -.05em;
    box-shadow: 0 24px 70px var(--icon-glow), inset 0 1px 0 rgba(255,255,255,.2);
  }
  .settings-section { margin-bottom: 18px; }
  .contact-card {
    min-height: 92px;
    padding: 16px;
    display: grid;
    grid-template-columns: 42px 1fr;
    gap: 14px;
    align-items: center;
  }
  .contact-card .icon {
    width: 38px;
    height: 38px;
    color: var(--icon-active);
    filter: drop-shadow(0 0 12px var(--icon-glow));
  }
  .contact-card strong { display: block; font-size: 1.08rem; letter-spacing: -.04em; }
  .contact-card small { display: block; color: var(--muted); font-weight: 850; margin-top: 3px; }
  .muted-line { color: var(--muted); margin: 6px 0 0; line-height: 1.35; font-weight: 740; }
  .action-card small { margin-left: auto; font-size: .78rem; max-width: 42%; text-align: right; }
}
