:root {
    --bg: #081018;
    --surface: #0f1822;
    --surface-2: #151f2a;
    --text: #f8fafc;
    --muted: #9aa7b5;
    --line: #243241;
    --accent: #27c3ff;
    --accent-dark: #0798d0;
    --success: #38d39f;
    --warning: #ffbe55;
    --danger: #ff6b78;
    --radius: 16px;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }

.app-shell { min-height: 100vh; padding-bottom: 76px; }
.topbar {
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    background: rgba(8,16,24,.96);
    backdrop-filter: blur(8px);
    z-index: 10;
}
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; letter-spacing: -.02em; }
.brand-dot { width: 10px; height: 10px; border-radius: 999px; background: var(--accent); box-shadow: 0 0 18px rgba(39,195,255,.6); }
.logout-link { color: var(--muted); font-size: 14px; }
.page { width: min(100%, 760px); margin: 0 auto; padding: 18px 14px 26px; }
.page-title { margin: 4px 0 4px; font-size: 25px; letter-spacing: -.04em; }
.page-subtitle { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.section-title { margin: 24px 0 10px; font-size: 14px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.stat strong { display: block; font-size: 28px; line-height: 1; margin-bottom: 6px; }
.stat span { color: var(--muted); font-size: 13px; }

.primary-btn, .secondary-btn {
    width: 100%;
    min-height: 54px;
    border: 0;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 850;
    cursor: pointer;
}
.primary-btn { background: var(--accent); color: #00121b; }
.primary-btn:active { background: var(--accent-dark); }
.secondary-btn { border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.cta-new { margin: 14px 0 20px; font-size: 17px; }

.list { display: grid; gap: 8px; }
.list-item { display: block; padding: 13px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.list-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.list-company { font-weight: 800; letter-spacing: -.02em; }
.list-meta { margin-top: 4px; color: var(--muted); font-size: 13px; line-height: 1.35; }
.list-time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.empty { padding: 24px 12px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 14px; }

.badge { display: inline-flex; align-items: center; min-height: 24px; margin-top: 9px; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; background: #1a2633; color: #cad5df; }
.badge.is-interested { background: rgba(255,190,85,.12); color: var(--warning); }
.badge.is-proposal { background: rgba(39,195,255,.12); color: #7ddcff; }
.badge.is-closed { background: rgba(56,211,159,.12); color: var(--success); }
.badge.is-lost { background: rgba(255,107,120,.12); color: #ff9ba5; }
.badge.is-return { background: rgba(255,190,85,.12); color: var(--warning); }

.form { display: grid; gap: 15px; }
.field { display: grid; gap: 7px; }
.field label, .field-label { font-size: 13px; color: #dce5ed; font-weight: 750; }
.field input, .field select, .field textarea {
    width: 100%;
    min-height: 50px;
    padding: 12px 13px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    outline: none;
}
.field textarea { min-height: 88px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(39,195,255,.1); }
.field small { color: var(--muted); }

.toggle-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span { display: flex; min-height: 48px; align-items: center; justify-content: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-weight: 800; text-align: center; font-size: 13px; }
.choice input:checked + span { border-color: var(--accent); background: rgba(39,195,255,.12); color: #8ce5ff; box-shadow: inset 0 0 0 1px var(--accent); }
.decision-extra { display: grid; gap: 15px; padding-left: 10px; border-left: 2px solid var(--line); }
.decision-extra[hidden] { display: none; }
.form-actions {
    display: grid;
    gap: 9px;
    margin-top: 4px;
    position: sticky;
    bottom: 70px;
    z-index: 8;
    padding: 10px 0 4px;
    background: linear-gradient(to bottom, rgba(8,16,24,0), var(--bg) 28%);
}

.filters { display: grid; gap: 8px; margin-bottom: 16px; }
.filters-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filters input, .filters select { width: 100%; min-height: 46px; padding: 10px 12px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.filter-actions { display: flex; gap: 8px; }
.filter-actions button, .filter-actions a { min-height: 44px; flex: 1; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-weight: 750; display: flex; align-items: center; justify-content: center; }

.return-group { margin-bottom: 22px; }
.return-date { font-weight: 800; }
.notes-preview { margin-top: 8px; color: #d3dde5; font-size: 13px; line-height: 1.4; }

.detail-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.meta-box { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; color: var(--muted); font-size: 12px; }
.meta-box strong { display: block; color: var(--text); margin-top: 3px; font-size: 13px; }

.flash { position: fixed; top: 66px; left: 50%; transform: translateX(-50%); width: min(calc(100% - 28px), 520px); padding: 11px 14px; border-radius: 12px; background: #0d3f34; color: #a7f3d0; border: 1px solid #176a56; font-weight: 800; z-index: 30; animation: flashOut .2s ease 2.2s forwards; }
@keyframes flashOut { to { opacity: 0; visibility: hidden; } }

.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; height: calc(64px + env(safe-area-inset-bottom)); padding: 0 8px env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(3, 1fr); background: rgba(8,16,24,.98); border-top: 1px solid var(--line); z-index: 20; }
.bottom-nav a { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; font-weight: 750; }
.bottom-nav a.active { color: var(--accent); }

.login-wrap { min-height: calc(100vh - 100px); display: grid; align-items: center; }
.login-card { width: 100%; max-width: 420px; margin: 0 auto; }
.login-card h1 { margin-bottom: 6px; }
.login-card p { color: var(--muted); margin-top: 0; }
.error { padding: 11px 12px; margin-bottom: 12px; border-radius: 12px; color: #ffc4c9; background: rgba(255,107,120,.1); border: 1px solid rgba(255,107,120,.3); }
.install-note { margin-top: 18px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.export-links { display: flex; gap: 8px; margin-top: 18px; }
.export-links a { flex: 1; min-height: 42px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 11px; color: var(--muted); font-size: 13px; font-weight: 750; }

@media (min-width: 640px) {
    .page { padding-left: 22px; padding-right: 22px; }
}
