/* EZOS Mini App — Soft Minimal UI */

:root {
    --bg: #f4f5fb;
    --surface: #ffffff;
    --surface-2: #f1f2f8;
    --surface-3: #e8e9f3;
    --border: rgba(30, 32, 70, 0.07);
    --text: #161833;
    --text-2: #5d6080;
    --text-3: #9a9cb5;

    --accent: #5b4cf0;
    --accent-2: #7c5cff;
    --accent-soft: rgba(91, 76, 240, 0.11);
    --accent-text: #ffffff;

    --expense: #e5484d;
    --expense-soft: #fff1f1;
    --expense-tint: rgba(229, 72, 77, 0.1);
    --overtime: #12a87a;
    --overtime-soft: #ecfaf4;
    --overtime-tint: rgba(18, 168, 122, 0.12);
    --warning: #d98a00;
    --warning-soft: rgba(245, 166, 35, 0.14);

    --btn-1: #7c5cff;
    --btn-2: #5b4cf0;
    --hero-1: #1b2050;
    --hero-2: #2b2f74;

    --shadow-sm: 0 1px 2px rgba(22, 24, 51, 0.04), 0 2px 8px rgba(22, 24, 51, 0.04);
    --shadow-md: 0 8px 28px rgba(22, 24, 51, 0.08);
    --shadow-accent: 0 8px 22px rgba(91, 76, 240, 0.35);

    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 20px;
    --r-xl: 24px;

    --nav-h: 68px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
    --bg: #0f1020;
    --surface: #181a2e;
    --surface-2: #202238;
    --surface-3: #2a2d47;
    --border: rgba(255, 255, 255, 0.06);
    --text: #eef0ff;
    --text-2: #a8abc8;
    --text-3: #6f7293;

    --accent: #8b7bff;
    --accent-2: #a08fff;
    --accent-soft: rgba(139, 123, 255, 0.16);

    --expense: #ff6b70;
    --expense-soft: rgba(255, 107, 112, 0.09);
    --expense-tint: rgba(255, 107, 112, 0.14);
    --overtime: #34d39e;
    --overtime-soft: rgba(52, 211, 158, 0.08);
    --overtime-tint: rgba(52, 211, 158, 0.14);
    --warning: #ffb547;
    --warning-soft: rgba(255, 181, 71, 0.14);

    --btn-1: #7a66ff;
    --btn-2: #5240e6;
    --hero-1: #23266a;
    --hero-2: #33288a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.45);
    --shadow-accent: 0 8px 22px rgba(139, 123, 255, 0.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html { background: var(--bg); }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.ic {
    width: 18px; height: 18px; flex: 0 0 auto;
    fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
    vertical-align: middle;
}
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }

/* ==================== LAYOUT ==================== */

.app {
    max-width: 560px;
    margin: 0 auto;
    padding: 6px 16px calc(var(--nav-h) + var(--safe-b) + 92px);
}

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 0 12px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
    width: 34px; height: 34px; border-radius: 11px;
    display: grid; place-items: center; color: #fff;
    background: linear-gradient(135deg, var(--accent-2), var(--accent));
    box-shadow: var(--shadow-accent);
}
.brand-name { font-size: 22px; font-weight: 750; letter-spacing: -0.02em; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.avatar {
    width: 40px; height: 40px; border-radius: 50%;
    display: grid; place-items: center; flex: 0 0 auto;
    font-weight: 700; color: #fff; font-size: 16px;
    background: linear-gradient(135deg, var(--accent-2), var(--accent));
}
.avatar.sm { width: 36px; height: 36px; font-size: 15px; }
.avatar.lg { width: 56px; height: 56px; font-size: 22px; }
.avatar.tone-1 { background: linear-gradient(135deg, #f59e8b, #e5484d); }
.avatar.tone-2 { background: linear-gradient(135deg, #5ee0b4, #12a87a); }
.avatar.tone-3 { background: linear-gradient(135deg, #7cc4ff, #2f7cf6); }
.avatar.tone-4 { background: linear-gradient(135deg, #ffc56b, #e08a00); }
.avatar-btn { border-radius: 50%; }
.avatar-btn:focus-visible, .icon-btn:focus-visible, .btn:focus-visible, .nav-item:focus-visible,
.row:focus-visible, .kpi:focus-visible, .fab:focus-visible, .seg-btn:focus-visible, .chip:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 2px;
}

.icon-btn {
    width: 40px; height: 40px; border-radius: 12px;
    display: inline-grid; place-items: center; flex: 0 0 auto;
    background: var(--surface); color: var(--text-2);
    box-shadow: var(--shadow-sm); border: 1px solid var(--border);
    transition: transform .12s ease, background .15s ease;
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn.ghost { background: var(--surface-2); box-shadow: none; border: 0; width: 34px; height: 34px; border-radius: 50%; }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 10px; box-shadow: none; background: transparent; border: 0; color: var(--text-3); }
.icon-btn.spin .ic { animation: spin .8s linear infinite; }

/* ==================== FILTERS ==================== */

.filters { display: flex; gap: 8px; margin-bottom: 14px; }
.pill-select {
    position: relative; flex: 1.2 1 0; min-width: 0;
    display: flex; align-items: center; gap: 6px;
    height: 42px; padding: 0 10px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 14px; box-shadow: var(--shadow-sm);
    color: var(--text-2);
}
.pill-select select {
    appearance: none; -webkit-appearance: none;
    border: 0; background: transparent; outline: none;
    flex: 1; min-width: 0; height: 100%;
    font-size: 14px; font-weight: 600; color: var(--text);
    text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
    padding-right: 18px;
}
.pill-select select option { color: #111; }
#adminUserSelectWrap { flex: 1 1 0; }
.pill-select > .ic:first-child { width: 16px; height: 16px; }
.pill-select .chevron { position: absolute; right: 10px; width: 16px; height: 16px; pointer-events: none; color: var(--text-3); }
.pill-select:focus-within { border-color: var(--accent); }

.custom-period { display: flex; align-items: center; gap: 8px; margin: -4px 0 14px; }
.custom-period .field { flex: 1; min-width: 0; height: 40px; padding: 0 10px; }

/* ==================== TABS ==================== */

.tab { display: none; }
.tab.active { display: block; animation: fadeIn .22s ease; }

/* ==================== CARDS ==================== */

.card {
    background: var(--surface);
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.card-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }

/* Hero */
.hero {
    position: relative; overflow: hidden;
    padding: 18px 18px 20px;
    border-radius: var(--r-xl);
    color: #fff;
    background:
        radial-gradient(120% 140% at 100% 0%, rgba(124, 92, 255, 0.55) 0%, rgba(124, 92, 255, 0) 55%),
        linear-gradient(140deg, var(--hero-2), var(--hero-1));
    box-shadow: 0 14px 34px rgba(27, 32, 80, 0.28);
    margin-bottom: 12px;
    min-height: 150px;
}
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; position: relative; z-index: 1; }
.hero-label { white-space: nowrap; display: flex; align-items: center; gap: 8px; font-size: 13px; color: rgba(255, 255, 255, 0.72); font-weight: 500; }
.hero-value {
    position: relative; z-index: 1;
    font-size: clamp(28px, 9vw, 38px); font-weight: 800; letter-spacing: -0.03em;
    margin-top: 10px; font-variant-numeric: tabular-nums; line-height: 1.1;
}
.hero-sub { position: relative; z-index: 1; margin-top: 4px; font-size: 13px; color: rgba(255, 255, 255, 0.6); }
.delta {
    display: inline-grid; grid-template-columns: auto auto; align-items: center; column-gap: 3px;
    padding: 5px 10px; border-radius: 12px; flex: 0 0 auto;
    font-size: 12px; font-weight: 700; white-space: nowrap;
    background: rgba(255, 255, 255, 0.12); backdrop-filter: blur(6px);
}
.delta .ic { width: 14px; height: 14px; }
.delta.up { color: #7ff0c4; }
.delta.down { color: #ffb1b4; }
.delta small { grid-column: 1 / -1; font-size: 10px; font-weight: 500; color: rgba(255, 255, 255, 0.6); }
.hero-bars {
    position: absolute; right: 14px; bottom: 0; height: 64px;
    display: flex; align-items: flex-end; gap: 5px; opacity: 0.9;
}
.hero-bars span {
    display: block; width: 9px; border-radius: 4px 4px 0 0; min-height: 4px;
    background: linear-gradient(180deg, rgba(160, 143, 255, 0.95), rgba(160, 143, 255, 0.25));
}

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.kpi {
    text-align: left; padding: 14px; border-radius: var(--r-lg);
    border: 1px solid var(--border); box-shadow: var(--shadow-sm);
    transition: transform .12s ease;
    min-width: 0;
}
.kpi:active { transform: scale(0.98); }
.kpi-expense { background: var(--expense-soft); }
.kpi-overtime { background: var(--overtime-soft); }
.kpi-head { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.kpi-icon { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; }
.kpi-icon .ic { width: 16px; height: 16px; }
.kpi-expense .kpi-icon { background: var(--expense-tint); color: var(--expense); }
.kpi-overtime .kpi-icon { background: var(--overtime-tint); color: var(--overtime); }
.kpi-go { margin-left: auto; width: 16px; height: 16px; color: var(--text-3); }
.kpi-value {
    margin-top: 10px; font-size: clamp(17px, 5.2vw, 21px); font-weight: 800; letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi-expense .kpi-value { color: var(--expense); }
.kpi-overtime .kpi-value { color: var(--overtime); }
.kpi-sub { font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* Split */
.split-card { padding: 14px 16px; margin-bottom: 18px; }
.split-bar {
    display: flex; height: 10px; border-radius: 999px; overflow: hidden;
    background: var(--surface-3); margin: 12px 0 10px; gap: 3px;
}
.split-bar .seg { display: block; height: 100%; width: 0; transition: width .5s ease; border-radius: 999px; }
.seg-overtime { background: var(--overtime); }
.seg-expense { background: var(--expense); }
.split-legend { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--text-2); }
.split-legend > div { display: flex; align-items: center; gap: 6px; }
.split-legend b { color: var(--text); font-variant-numeric: tabular-nums; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-overtime { background: var(--overtime); }
.dot-expense { background: var(--expense); }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 2px 8px; }
.section-head h3 { font-size: 16px; font-weight: 700; }
.link-btn { display: inline-flex; align-items: center; gap: 2px; color: var(--accent); font-weight: 600; font-size: 14px; }
.link-btn .ic { width: 16px; height: 16px; }

/* ==================== LISTS ==================== */

.list { overflow: hidden; }
.list + .day-label { margin-top: 14px; }
.day-label {
    display: flex; justify-content: space-between;
    font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-3); margin: 0 4px 6px;
}
.row {
    display: flex; align-items: center; gap: 12px;
    width: 100%; text-align: left;
    padding: 11px 8px 11px 14px;
    position: relative;
    transition: background .12s ease;
}
.row + .row::before {
    content: ""; position: absolute; top: 0; left: 64px; right: 0;
    border-top: 1px solid var(--border);
}
.row:active { background: var(--surface-2); }
.row-icon {
    width: 40px; height: 40px; border-radius: 13px; flex: 0 0 auto;
    display: grid; place-items: center;
}
.row-icon.expense { background: var(--expense-tint); color: var(--expense); }
.row-icon.overtime { background: var(--overtime-tint); color: var(--overtime); }
.row-icon.accent { background: var(--accent-soft); color: var(--accent); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 650; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub {
    font-size: 13px; color: var(--text-2); margin-top: 1px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-sub .sep { color: var(--text-3); margin: 0 4px; }
.row-end { text-align: right; flex: 0 0 auto; display: flex; align-items: center; gap: 2px; }
.row-end-text { display: flex; flex-direction: column; align-items: flex-end; }
.amount { font-weight: 750; font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amount.expense { color: var(--expense); }
.amount.overtime { color: var(--overtime); }
.row-meta { font-size: 12px; color: var(--text-3); margin-top: 1px; display: inline-flex; gap: 4px; align-items: center; }
.row-meta .ic { width: 12px; height: 12px; }
.row-chevron { color: var(--text-3); width: 16px; height: 16px; }

.list-summary { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-2); margin: 0 4px 10px; }
.list-summary b { color: var(--text); font-variant-numeric: tabular-nums; }

.skeleton-row {
    height: 62px; margin: 0;
    background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
    background-size: 200% 100%; animation: shimmer 1.2s infinite linear;
}
.skeleton-row + .skeleton-row { border-top: 1px solid var(--border); }

.empty {
    text-align: center; padding: 34px 20px; color: var(--text-3);
}
.empty .ic { width: 34px; height: 34px; margin-bottom: 8px; opacity: .7; stroke-width: 1.6; }
.empty p { font-size: 14px; }

/* Toolbar & search */
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.search {
    flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
    height: 42px; padding: 0 12px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    box-shadow: var(--shadow-sm); color: var(--text-3);
}
.search:focus-within { border-color: var(--accent); }
.search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font-size: 14px; color: var(--text); }
.search input::placeholder { color: var(--text-3); }

/* Segmented control */
.segmented {
    display: flex; padding: 4px; gap: 4px; margin-bottom: 12px;
    background: var(--surface-2); border-radius: 14px;
}
.seg-btn {
    flex: 1; height: 38px; border-radius: 11px;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font-size: 14px; font-weight: 600; color: var(--text-2);
    transition: background .15s ease, color .15s ease;
}
.seg-btn .ic { width: 16px; height: 16px; }
.seg-btn.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }

/* Chips */
.chips { display: flex; gap: 6px; overflow-x: auto; margin: -2px -16px 12px; padding: 2px 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
    flex: 0 0 auto; height: 32px; padding: 0 12px; border-radius: 999px;
    font-size: 13px; font-weight: 600; color: var(--text-2);
    background: var(--surface); border: 1px solid var(--border);
    display: inline-flex; align-items: center; gap: 6px;
}
.chip .count { font-size: 11px; color: var(--text-3); }
.chip.active { background: var(--btn-2); color: var(--accent-text); border-color: transparent; }
.chip.active .count { color: rgba(255, 255, 255, 0.75); }

/* Status badges */
.status {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
    text-transform: uppercase; letter-spacing: .03em; white-space: nowrap;
}
.status .ic { width: 12px; height: 12px; }
.status.active { background: var(--overtime-tint); color: var(--overtime); }
.status.pending { background: var(--warning-soft); color: var(--warning); }
.status.blocked { background: var(--expense-tint); color: var(--expense); }
.status.admin { background: var(--warning-soft); color: var(--warning); }
.status.archived { background: var(--surface-3); color: var(--text-2); }
.status.locked { background: var(--surface-3); color: var(--text-2); text-transform: none; letter-spacing: 0; font-weight: 600; }

.row.is-archived .row-title, .sub-row.is-archived .sub-name { color: var(--text-3); }

/* ==================== BREAKDOWN (expandable rows) ==================== */

.acc + .acc { border-top: 1px solid var(--border); }
.acc-head { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 12px 12px 14px; }
.acc-main { flex: 1; min-width: 0; }
.acc-bar { display: block; height: 4px; border-radius: 999px; background: var(--surface-3); margin-top: 7px; overflow: hidden; }
.acc-bar span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width .5s ease; }
.acc-arrow { color: var(--text-3); transition: transform .2s ease; width: 16px; height: 16px; }
.acc.open .acc-arrow { transform: rotate(180deg); }
.acc-body { display: none; padding: 0 14px 12px 66px; }
.acc.open .acc-body { display: block; }
.sub-row {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    padding: 8px 0; font-size: 14px;
}
.sub-row + .sub-row { border-top: 1px dashed var(--border); }
.sub-name { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--text-2); }
.sub-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-name .ic { width: 14px; height: 14px; color: var(--text-3); }
.sub-val { text-align: right; flex: 0 0 auto; }
.sub-val b { font-variant-numeric: tabular-nums; }
.sub-val .muted { display: block; font-size: 11px; }
.sub-actions { display: flex; gap: 2px; }

/* ==================== FAB ==================== */

.fab {
    position: fixed; z-index: 90;
    right: max(16px, calc(50vw - 280px + 16px));
    bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
    height: 52px; padding: 0 20px 0 16px; border-radius: 18px;
    display: inline-flex; align-items: center; gap: 8px;
    font-weight: 700; font-size: 15px; color: #fff;
    background: linear-gradient(135deg, var(--btn-1), var(--btn-2));
    box-shadow: var(--shadow-accent);
    transition: transform .15s ease, opacity .2s ease;
}
.fab .ic { width: 20px; height: 20px; stroke-width: 2.4; }
.fab:active { transform: scale(0.95); }

/* ==================== BOTTOM NAV ==================== */

.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
    display: flex; justify-content: space-around;
    padding: 6px 6px calc(6px + var(--safe-b));
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(160%) blur(18px);
    -webkit-backdrop-filter: saturate(160%) blur(18px);
    border-top: 1px solid var(--border);
}
.nav-item {
    flex: 1; max-width: 110px;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    font-size: 11px; font-weight: 600; color: var(--text-3);
    padding: 2px 0;
}
.nav-pill {
    width: 52px; height: 30px; border-radius: 999px;
    display: grid; place-items: center;
    transition: background .2s ease, color .2s ease;
}
.nav-pill .ic { width: 21px; height: 21px; }
.nav-item.active { color: var(--accent); }
.nav-item.active .nav-pill { background: var(--accent-soft); }
.nav-item.active .ic { stroke-width: 2.3; }

/* ==================== SHEETS / MODALS ==================== */

.modal-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(12, 13, 30, 0.45);
    display: flex; align-items: flex-end; justify-content: center;
    opacity: 0; pointer-events: none;
    transition: opacity .22s ease;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.sheet {
    width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
    background: var(--surface);
    border-radius: 24px 24px 0 0;
    padding: 8px 18px calc(18px + var(--safe-b));
    transform: translateY(30px);
    transition: transform .25s cubic-bezier(.2, .8, .2, 1);
    overscroll-behavior: contain;
}
.modal-overlay.active .sheet { transform: none; }
.sheet-grip { width: 38px; height: 5px; border-radius: 999px; background: var(--surface-3); margin: 0 auto 10px; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.sheet-head h3 { font-size: 18px; font-weight: 750; letter-spacing: -0.01em; word-break: break-word; }
.sheet-sub { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.sheet-footer { display: flex; gap: 10px; margin-top: 18px; }
.sheet-footer .btn { flex: 1; }

.detail:empty { display: none; }
.detail { background: var(--surface-2); border-radius: var(--r-md); padding: 4px 14px; margin-bottom: 12px; }
.detail-amount { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; padding: 10px 0 6px; font-variant-numeric: tabular-nums; }
.detail-amount.expense { color: var(--expense); }
.detail-amount.overtime { color: var(--overtime); }
.detail-row { display: flex; gap: 10px; padding: 9px 0; font-size: 14px; }
.detail-row + .detail-row { border-top: 1px solid var(--border); }
.detail-row .ic { width: 16px; height: 16px; color: var(--text-3); margin-top: 2px; }
.detail-key { color: var(--text-3); width: 92px; flex: 0 0 auto; }
.detail-val { flex: 1; min-width: 0; word-break: break-word; white-space: pre-wrap; }

.menu { display: flex; flex-direction: column; gap: 6px; }
.menu-item {
    display: flex; align-items: center; gap: 12px;
    width: 100%; padding: 13px 14px; border-radius: var(--r-md);
    background: var(--surface-2); font-weight: 600; font-size: 15px; text-align: left;
}
.menu-item:active { background: var(--surface-3); }
.menu-item .ic { color: var(--accent); }
.menu-item.danger { color: var(--expense); }
.menu-item.danger .ic { color: var(--expense); }
.menu-item.positive .ic { color: var(--overtime); }
.menu-note { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); padding: 6px 4px; }
.menu-note .ic { width: 15px; height: 15px; }

/* Forms */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin: 0 0 6px 2px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field {
    width: 100%; height: 46px; padding: 0 14px;
    background: var(--surface-2); border: 1px solid transparent; border-radius: var(--r-md);
    font-size: 15px; color: var(--text); outline: none;
    transition: border-color .15s ease, background .15s ease;
}
select.field { appearance: none; -webkit-appearance: none; padding-right: 30px;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
    background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
    background-size: 5px 5px; background-repeat: no-repeat; }
select.field option { color: #111; }
textarea.field { height: auto; min-height: 72px; padding: 12px 14px; resize: vertical; }
input[type="file"].field { padding: 11px 14px; font-size: 13px; }
.field:focus { border-color: var(--accent); background: var(--surface); }
.field-amount { height: 58px; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.form-error {
    margin-top: 6px; padding: 10px 12px; border-radius: var(--r-sm);
    background: var(--expense-tint); color: var(--expense); font-size: 13px; font-weight: 600;
}
.receipt-current { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.preview {
    background: var(--overtime-soft); border: 1px solid var(--overtime-tint);
    border-radius: var(--r-md); padding: 12px 14px; margin-top: 4px;
}
.preview-label { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.preview-label .ic { width: 15px; height: 15px; color: var(--overtime); }
.preview-value { font-size: 22px; font-weight: 800; color: var(--overtime); margin-top: 4px; font-variant-numeric: tabular-nums; }
.preview-sub { font-size: 12px; color: var(--text-2); }

.receipt-viewer img { width: 100%; border-radius: var(--r-md); display: block; }

/* Buttons */
.btn {
    height: 48px; padding: 0 18px; border-radius: var(--r-md);
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font-weight: 700; font-size: 15px;
    transition: transform .12s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: .6; pointer-events: none; }
.btn-sm { height: 38px; padding: 0 12px; font-size: 13px; border-radius: 12px; }
.btn-sm .ic { width: 16px; height: 16px; }
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--btn-1), var(--btn-2)); box-shadow: var(--shadow-accent); }
.btn-soft { background: var(--surface-2); color: var(--text); }
.btn-accent-soft { background: var(--accent-soft); color: var(--accent); }
.btn-danger-soft { background: var(--expense-tint); color: var(--expense); }
.btn-row { display: flex; gap: 8px; margin-bottom: 12px; }
.btn-row .btn { flex: 1; }

/* Gate */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate-card { text-align: center; max-width: 320px; }
.gate-icon {
    width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 16px;
    display: grid; place-items: center; background: var(--accent-soft); color: var(--accent);
}
.gate-icon .ic { width: 28px; height: 28px; }
.gate-card h2 { font-size: 20px; margin-bottom: 8px; }
.gate-card p { color: var(--text-2); }

/* Profile sheet */
.profile { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.profile-name { font-size: 18px; font-weight: 750; }

/* Toasts */
.toast-container {
    position: fixed; top: calc(10px + env(safe-area-inset-top, 0px)); left: 16px; right: 16px; z-index: 2000;
    display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
    display: flex; align-items: center; gap: 10px; max-width: 520px; width: 100%;
    padding: 12px 14px; border-radius: var(--r-md);
    background: var(--surface); color: var(--text); box-shadow: var(--shadow-md); border: 1px solid var(--border);
    font-size: 14px; font-weight: 600;
    animation: toastIn .25s ease; transition: opacity .3s ease, transform .3s ease;
}
.toast .ic { width: 20px; height: 20px; }
.toast-success .ic { color: var(--overtime); }
.toast-error .ic { color: var(--expense); }
.toast.hide { opacity: 0; transform: translateY(-10px); }

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin .8s linear infinite; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (max-width: 360px) {
    .app { padding-left: 12px; padding-right: 12px; }
    .kpi { padding: 12px; }
    .nav-pill { width: 44px; }
    .nav-item { font-size: 10px; }
    .fab span { display: none; }
    .fab { padding: 0; width: 52px; justify-content: center; }
}

/* Block-level spans inside button rows */
.row-main, .row-title, .row-sub, .acc-main { display: block; }
.row-end-text > span { display: block; }
.row-end-text .row-meta { display: inline-flex; }
.row-title .ic { width: 14px; height: 14px; color: var(--warning); margin-top: -2px; }
button.acc-main { text-align: left; }
.acc-head > .row-end { gap: 0; }
.acc-body .row.sub-row { padding: 8px 0; gap: 10px; }
.acc-body .row.sub-row::before { display: none; }
.acc-body .row.sub-row .row-end { gap: 6px; }
.acc.is-archived .row-title { color: var(--text-3); }
.profile { margin-bottom: 12px; }
.profile .status { margin-top: 4px; }

input[type="file"].field::file-selector-button {
    border: 0; border-radius: 9px; padding: 6px 12px; margin-right: 10px;
    background: var(--accent-soft); color: var(--accent); font-weight: 700; cursor: pointer;
}
input[type="file"].field { color: var(--text-2); height: auto; }

/* Theme switcher in profile */
.theme-block { margin-bottom: 12px; }
.theme-label { font-size: 12px; font-weight: 600; color: var(--text-2); margin: 0 0 6px 2px; }
.theme-switch { margin-bottom: 0; }
.theme-switch .seg-btn { font-size: 13px; gap: 5px; padding: 0 4px; min-width: 0; }
.theme-switch .seg-btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
:root[data-theme="dark"] select.field option, :root[data-theme="dark"] .pill-select select option { color: #eef0ff; background: #181a2e; }
