:root {
    --primary: #0f766e;
    --primary-dark: #115e59;
    --primary-light: #ccfbf1;
    --bg: #f5f7fb;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --line: #e5e7eb;
    --ok: #166534;       --ok-bg: #ecfdf5;
    --warn: #b45309;     --warn-bg: #fff7ed;
    --danger: #b91c1c;   --danger-bg: #fef2f2;
    --blue: #1d4ed8;     --blue-bg: #eff6ff;
    --nav-h: 64px;
    --header-h: 56px;
    --radius: 16px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-tap-highlight-color: transparent; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.5;
    padding-bottom: var(--nav-h);
    min-height: 100dvh;
}

a { color: inherit; text-decoration: none; }

/* ── App Header ─────────────────────────────────── */
.app-header {
    position: sticky;
    top: 0;
    z-index: 200;
    height: var(--header-h);
    background: var(--card);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
}

.header-back {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 20px;
    color: var(--muted);
    flex-shrink: 0;
}

.header-logo {
    height: 32px;
    width: auto;
}

.header-title {
    font-size: 17px;
    font-weight: 700;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ── Bottom Nav ──────────────────────────────────── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-h);
    background: var(--card);
    border-top: 1px solid var(--line);
    display: flex;
    z-index: 200;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
    padding: 6px 0 10px;
    transition: color .15s;
    -webkit-user-select: none;
    user-select: none;
}

.nav-item.active { color: var(--primary); }

.nav-icon {
    font-size: 22px;
    line-height: 1;
}

/* ── Page Content ────────────────────────────────── */
.page {
    max-width: 800px;
    margin: 0 auto;
    padding: 16px;
}

.page-wide {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
}

/* ── Cards ───────────────────────────────────────── */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.card-body { padding: 16px; }

.card-link {
    display: block;
    transition: transform .12s, box-shadow .12s;
}

.card-link:active { transform: scale(.98); }

/* ── Section ─────────────────────────────────────── */
.section {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}

.section-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
    margin-bottom: 12px;
}

/* ── Buttons ─────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    appearance: none;
    border: 0;
    border-radius: 12px;
    padding: 12px 18px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity .15s, transform .1s;
    white-space: nowrap;
    text-decoration: none;
    min-height: 48px;
}

.btn:active { transform: scale(.97); opacity: .9; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--line); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-ok { background: var(--ok-bg); color: var(--ok); }
.btn-sm { padding: 8px 14px; font-size: 13px; min-height: 36px; border-radius: 10px; }
.btn-icon { width: 48px; height: 48px; padding: 0; border-radius: 50%; font-size: 20px; }
.btn-full { width: 100%; }

/* ── Badges ──────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge-ok      { background: var(--ok-bg);     color: var(--ok); }
.badge-warn    { background: var(--warn-bg);   color: var(--warn); }
.badge-danger  { background: var(--danger-bg); color: var(--danger); }
.badge-blue    { background: var(--blue-bg);   color: var(--blue); }
.badge-muted   { background: var(--bg);        color: var(--muted); }

/* ── Forms ───────────────────────────────────────── */
.field { margin-bottom: 14px; }

.field label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 14px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    font-size: 16px;
    font-family: inherit;
    color: var(--text);
    background: var(--card);
    transition: border-color .15s;
    -webkit-appearance: none;
    appearance: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.field textarea { min-height: 100px; resize: vertical; }

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

/* ── List items ──────────────────────────────────── */
.list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    transition: background .1s;
}

.list-item:last-child { border-bottom: 0; }
.list-item:active { background: var(--bg); }

.list-item-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.list-item-body { flex: 1; min-width: 0; }

.list-item-title {
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-sub {
    font-size: 13px;
    color: var(--muted);
    margin-top: 2px;
}

.list-item-right {
    text-align: right;
    font-size: 13px;
    color: var(--muted);
    flex-shrink: 0;
}

/* ── Stats grid ──────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
}

.stat-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--muted);
    margin-bottom: 6px;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
}

/* ── Search bar ──────────────────────────────────── */
.search-bar {
    position: sticky;
    top: var(--header-h);
    z-index: 100;
    background: var(--bg);
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
}

.search-bar input {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    font-size: 16px;
    background: var(--card);
}

.search-bar input:focus { outline: none; border-color: var(--primary); }

/* ── Alert ───────────────────────────────────────── */
.alert {
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 14px;
    font-size: 14px;
    font-weight: 600;
}

.alert-ok     { background: var(--ok-bg);     color: var(--ok); }
.alert-danger { background: var(--danger-bg); color: var(--danger); }

/* ── Hero ────────────────────────────────────────── */
.hero {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 12px;
}

/* ── Empty state ─────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--muted);
}

.empty-state-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state-title { font-size: 17px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty-state-desc { font-size: 14px; }

/* ── FAB ─────────────────────────────────────────── */
.fab {
    position: fixed;
    bottom: calc(var(--nav-h) + 16px);
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 28px;
    border: 0;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(15,118,110,.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 150;
    transition: transform .15s, box-shadow .15s;
}

.fab:active { transform: scale(.92); }

/* ── Divider ─────────────────────────────────────── */
.divider { height: 1px; background: var(--line); margin: 0; }

/* ── Quick actions ───────────────────────────────── */
.quick-actions {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 0 0 4px;
    scrollbar-width: none;
}

.quick-actions::-webkit-scrollbar { display: none; }

.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 72px;
    padding: 12px 8px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text);
    text-align: center;
    cursor: pointer;
    transition: transform .12s;
}

.quick-action:active { transform: scale(.95); }
.quick-action-icon { font-size: 24px; }

/* ── Responsive ──────────────────────────────────── */
@media (min-width: 640px) {
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
    .field-row { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 768px) {
    body { padding-bottom: 0; }
    .bottom-nav { display: none; }
    .search-bar { position: static; border: 0; padding: 0; margin-bottom: 12px; }
    .fab { bottom: 24px; }
}
