:root {
    --bg: #f4f7fb;
    --card: #ffffff;
    --text: #16202a;
    --muted: #6f7b8a;
    --primary: #0a84ff;
    --primary-2: #0066d6;
    --danger: #d62839;
    --success: #1f9d55;
    --warning: #f59e0b;
    --border: #e6ebf2;
    --shadow: 0 8px 24px rgba(10, 20, 40, .08);
    --radius: 22px;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.app-shell {
    max-width: 760px;
    margin: 0 auto;
    min-height: 100vh;
    padding: 18px 14px 95px;
}
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}
.brand { font-size: 26px; font-weight: 800; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 14px;
}
.auth-card { margin-top: 28px; }
.section-title {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px;
}
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat {
    background: linear-gradient(180deg,#fff,#f8fbff);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 14px;
}
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 24px; font-weight: 800; margin-top: 6px; }
.stat.success .value { color: var(--success); }
.stat.danger .value { color: var(--danger); }
.stat.primary .value { color: var(--primary); }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input, select, textarea, button { font: inherit; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 16px;
    padding: 12px 14px;
    outline: none;
}
textarea { min-height: 90px; resize: vertical; }
.form-group { margin-bottom: 12px; }
.btn {
    border: 0;
    background: linear-gradient(180deg, var(--primary), var(--primary-2));
    color: #fff;
    border-radius: 16px;
    padding: 12px 16px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}
.btn-secondary {
    background: #eef5ff;
    color: var(--primary-2);
}
.ghost-btn {
    text-decoration: none;
    color: var(--text);
    padding: 9px 12px;
    border-radius: 14px;
    background: #fff;
    box-shadow: var(--shadow);
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bottom-nav {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: min(720px, calc(100% - 20px));
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    background: rgba(255,255,255,.95);
    backdrop-filter: blur(12px);
    padding: 10px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,.12);
}
.bottom-nav a {
    text-decoration: none;
    color: var(--muted);
    text-align: center;
    padding: 10px 4px;
    border-radius: 14px;
    font-size: 12px;
    font-weight: 700;
}
.bottom-nav a.active { color: var(--primary); background: #edf5ff; }
.alert {
    padding: 12px 14px;
    border-radius: 16px;
    margin-bottom: 12px;
    font-size: 14px;
}
.alert-success { background: #eaf8ef; color: #166534; }
.alert-danger { background: #ffe9e9; color: #991b1b; }
.table-list { display: grid; gap: 10px; }
.list-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 12px;
}
.badge {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
}
.badge-income { background: #eaf8ef; color: #166534; }
.badge-expense { background: #fff2e3; color: #9a4d00; }
.badge-fixed { background: #eef5ff; color: #0b4dbb; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.day-head, .day-cell { text-align: center; border-radius: 14px; padding: 10px 4px; }
.day-head { font-size: 12px; color: var(--muted); font-weight: 800; }
.day-cell {
    background: #fff;
    border: 1px solid var(--border);
    min-height: 58px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-decoration: none;
    color: var(--text);
}
.day-cell.work { border-color: #cfe6ff; background: #f7fbff; }
.day-cell.off { background: #fff3f3; border-color: #ffd7d7; }
.day-cell.empty { background: transparent; border: 0; }
.inline-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.progress {
    height: 12px;
    background: #eef2f7;
    border-radius: 999px;
    overflow: hidden;
}
.progress > div { height: 100%; background: linear-gradient(90deg,var(--primary),#55a7ff); }
.kpi-sub { font-size: 13px; color: var(--muted); margin-top: 6px; }
.help { font-size: 12px; color: var(--muted); margin-top: 4px; }
@media (max-width: 560px) {
    .grid-2, .grid-3, .row { grid-template-columns: 1fr; }
    .stat .value { font-size: 22px; }
}
.weekday-pills { display:flex; gap:8px; flex-wrap:wrap; }
.pill-check { position:relative; }
.pill-check input { position:absolute; opacity:0; pointer-events:none; }
.pill-check span {
    display:inline-block; padding:10px 14px; border-radius:999px; border:1px solid var(--border);
    background:#f8fbff; color:var(--text); font-size:13px; font-weight:700;
}
.pill-check input:checked + span { background:#eaf3ff; border-color:#b9d7ff; color:var(--primary-2); }
.planning-legend { display:flex; gap:14px; flex-wrap:wrap; margin:8px 0 12px; color:var(--muted); font-size:12px; }
.dot { display:inline-block; width:10px; height:10px; border-radius:50%; margin-right:6px; }
.dot-work { background:#cfe6ff; }
.dot-off { background:#ffd7d7; }
.dot-selected { background:#ffb4b4; }
.day-cell input { width:auto; margin:0 0 6px; }
.day-cell small { color:var(--muted); font-size:11px; margin-top:4px; }
.day-cell.selected-off { background:#fff0f0; border-color:#ffb4b4; }
.planning-stats .stat .value { font-size:20px; }
.input-with-actions { display:grid; grid-template-columns: 1fr auto; gap:8px; align-items:center; }
.mini-btn {
    text-decoration:none;
    border:1px solid var(--border);
    background:#f8fbff;
    color:var(--primary-2);
    padding:12px 14px;
    border-radius:16px;
    font-weight:700;
    white-space:nowrap;
    cursor:pointer;
}
.category-field-wrap {
    border: 1px solid transparent;
    border-radius: 20px;
    padding: 0;
    transition: .2s ease;
}
.category-field-wrap.is-open {
    background: linear-gradient(180deg,#f8fbff,#fff);
    border-color: #cfe1ff;
    padding: 10px;
}
.manage-toggle {
    display:flex;
    align-items:center;
    gap:8px;
    justify-content:center;
}
.manage-toggle.is-active {
    background: linear-gradient(180deg, #0a84ff, #0066d6);
    color:#fff;
    border-color: transparent;
    box-shadow: 0 10px 24px rgba(10,132,255,.22);
}
.manage-dot {
    width:10px;
    height:10px;
    border-radius:50%;
    background: currentColor;
    opacity:.7;
}
.category-inline-panel {
    display:none;
    margin-top:12px;
    border:1px solid #dbe7fb;
    border-radius:20px;
    background:#fff;
    padding:14px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.8), 0 10px 24px rgba(21,54,110,.08);
}
.category-inline-panel.is-visible { display:block; animation: panelIn .18s ease-out; }
@keyframes panelIn {
    from { opacity:0; transform: translateY(-6px); }
    to { opacity:1; transform: translateY(0); }
}
.category-panel-header {
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:12px;
    margin-bottom:12px;
}
.category-panel-title { font-weight:800; font-size:15px; }
.panel-close-btn {
    border:1px solid var(--border);
    background:#fff;
    border-radius:12px;
    padding:10px 12px;
    cursor:pointer;
    color:var(--muted);
}
.category-type-tabs {
    display:flex;
    gap:8px;
    flex-wrap:wrap;
    margin-bottom:12px;
}
.category-tab {
    border:1px solid var(--border);
    background:#f7faff;
    color:var(--text);
    border-radius:999px;
    padding:10px 14px;
    font-weight:700;
    cursor:pointer;
}
.category-tab.is-active {
    background:#eaf3ff;
    color:var(--primary-2);
    border-color:#bfd9ff;
}
.compact-row { align-items:end; }
.category-list-block { display:none; margin-top:12px; }
.category-list-block.is-active { display:block; }
.category-list-head {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:8px;
    margin-bottom:10px;
}
.category-chip-list { display:grid; gap:10px; }
.category-chip-card {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
    padding:10px;
    border:1px solid var(--border);
    border-radius:16px;
    background:#fbfdff;
}
.category-chip {
    border:0;
    background:#eef5ff;
    color:#0b4dbb;
    border-radius:999px;
    padding:10px 14px;
    font-weight:800;
    cursor:pointer;
}
.chip-actions { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.text-action {
    border:0;
    background:none;
    color:var(--primary-2);
    font-weight:700;
    cursor:pointer;
    padding:0;
}
.text-action.danger { color:var(--danger); }
.category-manager-form { margin-bottom: 8px; }
@media (max-width: 560px) {
    .input-with-actions { grid-template-columns: 1fr; }
    .mini-btn { text-align:center; }
    .category-panel-header, .category-chip-card { flex-direction:column; align-items:stretch; }
    .chip-actions { justify-content:flex-start; }
}

.app-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    z-index: 1200;
}
.app-modal.is-open { display: flex; }
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 40, .48);
    backdrop-filter: blur(3px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
    z-index: 1190;
}
.modal-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}
body.modal-open { overflow: hidden; }
.app-modal-card {
    width: min(100%, 620px);
    max-height: min(86vh, 820px);
    overflow: auto;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 22px 64px rgba(15, 23, 42, .24);
    border: 1px solid #dce7f7;
    padding: 16px;
    animation: modalRise .18s ease-out;
}
@keyframes modalRise {
    from { opacity: 0; transform: translateY(10px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.app-modal-header {
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:12px;
    margin-bottom:14px;
}
.modal-status {
    display:none;
    margin-bottom:12px;
    border-radius:16px;
    padding:10px 12px;
    font-size:13px;
    font-weight:600;
}
.modal-status.is-visible { display:block; }
.modal-status.success { background:#eaf8ef; color:#166534; }
.modal-status.error { background:#ffe9e9; color:#991b1b; }
.panel-close-btn {
    border:1px solid var(--border);
    background:#fff;
    color:var(--text);
    border-radius:14px;
    padding:10px 12px;
    cursor:pointer;
    font-weight:700;
}
.category-panel-title {
    font-size:18px;
    font-weight:800;
}
.category-type-tabs {
    display:flex;
    gap:8px;
    flex-wrap:wrap;
    margin-bottom:14px;
}
.category-tab {
    border:1px solid var(--border);
    background:#f8fbff;
    color:var(--text);
    padding:10px 12px;
    border-radius:999px;
    font-weight:700;
    cursor:pointer;
}
.category-tab.is-active {
    background:#eaf3ff;
    border-color:#bdd8ff;
    color:var(--primary-2);
}
.compact-row { align-items:end; }
.category-list-block { display:none; margin-top:14px; }
.category-list-block.is-active { display:block; }
.category-list-head {
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:8px;
    margin-bottom:10px;
}
.category-chip-list {
    display:grid;
    gap:10px;
}
.category-chip-card {
    display:grid;
    grid-template-columns:1fr auto;
    gap:10px;
    align-items:center;
    border:1px solid var(--border);
    border-radius:18px;
    padding:10px;
    background:#fcfdff;
}
.category-chip {
    border:1px solid #d8e6ff;
    background:#f4f8ff;
    color:#0b4dbb;
    border-radius:999px;
    padding:10px 12px;
    text-align:left;
    font-weight:700;
    cursor:pointer;
}
.chip-actions {
    display:flex;
    align-items:center;
    gap:8px;
    flex-wrap:wrap;
    justify-content:flex-end;
}
.text-action {
    border:0;
    background:none;
    color:#0b4dbb;
    cursor:pointer;
    font-weight:700;
    padding:4px 0;
}
.text-action.danger { color: var(--danger); }
@media (max-width: 560px) {
    .app-modal { align-items: end; padding: 0; }
    .app-modal-card {
        width: 100%;
        max-height: 90vh;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        padding-bottom: 22px;
    }
    .category-chip-card { grid-template-columns: 1fr; }
    .chip-actions { justify-content:flex-start; }
}

.topbar-actions { display:flex; align-items:center; gap:10px; }
.profile-avatar {
    width:44px; height:44px; border-radius:999px; background:#fff; box-shadow:var(--shadow);
    display:flex; align-items:center; justify-content:center; overflow:hidden; text-decoration:none;
    border:2px solid #fff;
}
.profile-avatar img { width:100%; height:100%; object-fit:cover; display:block; }
.profile-preview-wrap { display:flex; align-items:center; gap:14px; margin-bottom:12px; }
.profile-preview {
    width:88px; height:88px; border-radius:999px; overflow:hidden; background:#eef5ff; border:3px solid #fff; box-shadow:var(--shadow);
}
.profile-preview img { width:100%; height:100%; object-fit:cover; display:block; }
.file-help { font-size:12px; color:var(--muted); margin-top:6px; }
.danger-link { color: var(--danger); text-decoration:none; font-weight:700; }
@media (max-width:560px) {
    .topbar-actions { gap:8px; }
    .profile-avatar { width:42px; height:42px; }
    .profile-preview-wrap { align-items:flex-start; }
}

.tour-fab {
    position: fixed;
    right: 18px;
    bottom: 96px;
    width: 60px;
    height: 60px;
    border-radius: 999px;
    border: 0;
    background: linear-gradient(180deg, #0a84ff, #0066d6);
    color: #fff;
    font-size: 28px;
    box-shadow: 0 14px 30px rgba(10,132,255,.32);
    cursor: pointer;
    z-index: 1200;
}
.tour-layer[hidden] { display:none !important; }
.tour-layer {
    position: fixed;
    inset: 0;
    z-index: 1600;
}
.tour-backdrop {
    position:absolute;
    inset:0;
    background: rgba(19,34,58,.66);
}
.tour-highlight {
    position: fixed;
    border-radius: 22px;
    border: 2px solid rgba(255,255,255,.92);
    box-shadow: 0 0 0 9999px rgba(19,34,58,.38), 0 18px 40px rgba(8,24,48,.24);
    transition: all .18s ease;
    pointer-events: none;
    z-index: 1602;
}
.tour-popover {
    position: fixed;
    width: min(340px, calc(100vw - 28px));
    background: #fff;
    border-radius: 24px;
    padding: 16px;
    box-shadow: 0 24px 70px rgba(7,18,40,.28);
    z-index: 1603;
}
.tour-popover-head {
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:10px;
    margin-bottom:10px;
}
.tour-close {
    border:0;
    background:#eef5ff;
    color:#0b4dbb;
    width:40px;
    height:40px;
    border-radius:999px;
    font-size:30px;
    line-height:1;
    cursor:pointer;
}
.tour-popover-body { color: var(--text); line-height: 1.45; }
.tour-popover-foot { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-top:14px; }
.tour-step { font-size: 13px; color: var(--muted); font-weight: 700; }
.tour-actions { display:flex; gap:10px; }
body.tour-open { overflow: hidden; }
@media (max-width: 560px) {
    .tour-fab { width:56px; height:56px; font-size:26px; right:14px; bottom:92px; }
    .tour-popover { width: calc(100vw - 24px); padding: 14px; }
    .tour-actions { width:100%; justify-content:flex-end; }
    .tour-popover-foot { align-items:flex-end; flex-direction:column; }
}
