@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    --bg: #12141a;
    --bg-elevated: #191c24;
    --card: #191c24;
    --card-hover: #21252f;
    --card-dim: #15171d;
    --border: #2a2f3b;
    --text: #eef0f4;
    --text-dim: #9099ab;
    --text-faint: #5c6478;

    --ok: #5eead4;
    --ok-bg: #2a5a52;
    --warn: #f4c15c;
    --warn-bg: #4a3b1e;
    --critical: #f4736b;
    --critical-bg: #4a2321;

    --accent: #5eead4;
    --accent-bg: #2a5a52;

    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 10px;

    --font-body: 'Manrope', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;
}

* {
    box-sizing: border-box;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    padding-bottom: 90px;
}

#app {
    max-width: 640px;
    margin: 0 auto;
    padding: 16px 16px 24px;
}

a { color: inherit; }

h1, h2, h3 { margin: 0; font-weight: 700; }

.hidden { display: none !important; }

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

input, select {
    font-family: inherit;
    color: var(--text);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 15px;
    width: 100%;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
}

label {
    display: block;
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 6px;
    font-weight: 600;
}

.field {
    margin-bottom: 16px;
}

/* ---------- Top bar ---------- */
.topbar {
    position: relative;
    padding: 4px 56px 0 0;
    margin-bottom: 6px;
}

.topbar-icons {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    gap: 8px;
}

.topbar h1 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.topbar .date {
    font-size: 14.5px;
    color: var(--text-dim);
    margin-top: 5px;
    text-transform: capitalize;
}

.today-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent-bg);
    color: var(--accent);
    font-size: 12.5px;
    font-weight: 700;
    padding: 7px 14px;
    border-radius: 999px;
    margin: 16px 0 22px;
}

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-dim);
}
.icon-btn:active { background: var(--card-hover); }

/* ---------- Banner ---------- */
.banner-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.banner {
    background: var(--warn-bg);
    border: 1px solid rgba(245, 196, 81, 0.3);
    color: var(--warn);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}
.banner.critical {
    background: var(--critical-bg);
    border-color: rgba(242, 84, 91, 0.3);
    color: var(--critical);
}

/* ---------- Countdown tile (Spritze / Intervall) ---------- */
.countdown-tile {
    position: relative;
    background: linear-gradient(155deg, var(--card-hover), var(--bg-elevated));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 18px 16px;
    margin-bottom: 20px;
    overflow: hidden;
}
.countdown-tile::before {
    content: "";
    position: absolute;
    top: -40%;
    right: -20%;
    width: 180px;
    height: 180px;
    background: radial-gradient(circle, rgba(94, 234, 212, 0.14), transparent 70%);
    pointer-events: none;
}

.countdown-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.countdown-tile .label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--accent);
    font-weight: 700;
}

.countdown-tile .name {
    font-size: 18px;
    font-weight: 700;
    margin-top: 4px;
}

.ring {
    position: relative;
    width: 100px;
    height: 58px;
    flex-shrink: 0;
}
.ring-num {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.countdown-foot {
    display: flex;
    justify-content: space-between;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 12.5px;
    position: relative;
}
.countdown-foot .foot-label {
    display: block;
    color: var(--text-faint);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 3px;
}
.countdown-foot .order-by { color: var(--warn); font-weight: 700; }
.countdown-foot.status-critical .order-by { color: var(--critical); }

.btn-primary {
    background: var(--accent);
    color: #0b1220;
    font-weight: 700;
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-size: 14.5px;
    width: 100%;
}
.btn-primary:active { opacity: 0.85; }

.btn-secondary {
    background: var(--card-hover);
    color: var(--text);
    font-weight: 600;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.btn-ghost {
    color: var(--accent);
    font-weight: 600;
    font-size: 14px;
    padding: 8px 4px;
}

/* ---------- Slot sections ---------- */
.today-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 8px;
}

.slot-section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
}

.slot-section.slot-active {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent) inset;
}

.slot-section.slot-empty {
    padding: 9px 14px;
    opacity: 0.55;
}

.slot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.slot-section.slot-empty .slot-header {
    margin-bottom: 0;
}

.slot-header h2 {
    font-size: 12px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.slot-section.slot-active .slot-header h2 { color: var(--accent); }

.slot-header .count {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-faint);
}

.slot-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 10px;
}

.slot-card {
    background: var(--card-hover);
    border-radius: 8px;
    padding: 6px 8px;
}

.slot-card {
    font-weight: 600;
    font-size: 13px;
    line-height: 1.3;
}

/* ---------- Medication list ---------- */
.section-title {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin: 24px 0 10px;
    font-weight: 700;
}

.med-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.med-row {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.med-row .med-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    background: var(--accent-bg);
}
.med-row .med-icon.drop { background: #2a3a55; }
.med-row .med-icon.spritze { background: #3a2a55; }

.med-row .med-info {
    flex: 1;
    min-width: 0;
}

.med-row .med-name {
    font-weight: 700;
    font-size: 14.5px;
}

.med-row .med-meta {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 2px;
}

.med-row .med-note {
    font-size: 12px;
    color: var(--text-faint);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fill-bar {
    display: flex;
    gap: 3px;
    margin-top: 7px;
    max-width: 140px;
}
.fill-seg {
    flex: 1;
    height: 5px;
    border-radius: 3px;
    background: var(--border);
}
.fill-seg.on { background: var(--accent); }
.fill-seg.on.warn { background: var(--warn); }
.fill-seg.on.critical { background: var(--critical); }

.badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    white-space: nowrap;
    flex-shrink: 0;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.critical { background: var(--critical-bg); color: var(--critical); }

.take-btn {
    background: var(--accent-bg);
    color: var(--accent);
    font-weight: 700;
    font-size: 12.5px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}
.take-btn:active { opacity: 0.7; }

/* ---------- FAB ---------- */
.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--accent);
    color: #0b1220;
    font-size: 28px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(94, 234, 212, 0.35);
    z-index: 20;
}
.fab:active { transform: scale(0.95); }

/* ---------- Bottom sheet / modal ---------- */
.sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 30;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
@media (min-width: 640px) {
    .sheet-backdrop { align-items: center; }
}

.sheet {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px 20px calc(24px + env(safe-area-inset-bottom));
}
@media (min-width: 640px) {
    .sheet { border-radius: var(--radius-lg); max-height: 85vh; }
}

.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.sheet-header h2 { font-size: 18px; }

.close-btn {
    font-size: 22px;
    color: var(--text-dim);
    width: 32px;
    height: 32px;
}

.chip-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.chip {
    padding: 9px 14px;
    border-radius: 999px;
    background: var(--card);
    border: 1px solid var(--border);
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-dim);
}

.chip.selected {
    background: var(--accent-bg);
    border-color: var(--accent);
    color: var(--accent);
}

.weekday-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}
.weekday-grid .chip {
    padding: 9px 0;
    text-align: center;
}

.level-picker {
    display: flex;
    gap: 8px;
}
.level-picker .chip { flex: 1; text-align: center; }

.row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.sheet-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}
.sheet-actions .btn-primary { flex: 1; }

.danger-link {
    color: var(--critical);
    font-size: 13.5px;
    font-weight: 600;
    text-align: center;
    display: block;
    margin-top: 16px;
}

/* ---------- Login ---------- */
.login-screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 24px;
}

.login-screen h1 {
    font-size: 22px;
}

.login-screen p {
    color: var(--text-dim);
    font-size: 14px;
    text-align: center;
    margin: 0;
}

.pin-dots {
    display: flex;
    gap: 16px;
}
.pin-dots .dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--border);
}
.pin-dots .dot.filled {
    background: var(--accent);
    border-color: var(--accent);
}
.pin-dots .dot.error {
    background: var(--critical);
    border-color: var(--critical);
}

.keypad {
    display: grid;
    grid-template-columns: repeat(3, 72px);
    gap: 14px;
}

.keypad button {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--card);
    font-size: 24px;
    font-weight: 600;
    font-family: var(--font-mono);
}
.keypad button:active { background: var(--card-hover); }
.keypad button.key-empty { background: transparent; }

/* ---------- Paused list link ---------- */
.paused-link {
    display: block;
    text-align: center;
    margin-top: 18px;
    font-size: 11.5px;
    color: var(--text-faint);
}
.paused-link a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

/* ---------- Empty state ---------- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-dim);
}
