/* =========================================================
   RESET / BASE
========================================================= */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    font-size: 16px;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
        Roboto, Helvetica, Arial, sans-serif;
    background: #f3f4f6;
    color: #111827;
    line-height: 1.45;
}

/* Disable tap highlight */
button,
input,
select,
textarea {
    -webkit-tap-highlight-color: transparent;
}

/* =========================================================
   HEADER
========================================================= */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 64px;
    background: #0f172a;
    border-bottom: 1px solid #1e293b;
    z-index: 1000;
}

.header-inner {
    max-width: 1200px;
    height: 100%;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    color: #fff;
    font-size: 18px;
    font-weight: 600;
}

.app-header nav {
    display: flex;
    gap: 16px;
}

.app-header nav a {
    color: #cbd5f5;
    text-decoration: none;
    font-size: 14px;
}

.app-header nav a:hover {
    color: #fff;
}

.app-header .logout {
    color: #fb7185;
}

/* =========================================================
   CONTAINER
========================================================= */
.container {
    max-width: 1200px;
    margin: 80px auto 24px;
    padding: 0 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* =========================================================
   CARD / BOX
========================================================= */
.box {
    background: #ffffff;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
    transition: transform .15s ease, box-shadow .15s ease;
}

/* =========================================================
   TYPOGRAPHY
========================================================= */
h1 { font-size: 1.8rem; margin: 0 0 16px; }
h2 { font-size: 1.3rem; margin: 0 0 12px; }
h3 { font-size: 1.05rem; margin: 0 0 12px; font-weight: 600; }
h4 { font-size: 0.95rem; margin: 0 0 8px; }

.muted { color: #6b7280; font-size: 0.9rem; }
.green { color: #16a34a; font-weight: 600; }
.red { color: #dc2626; font-weight: 600; }

/* =========================================================
   BUTTONS
========================================================= */
.button {
    border: none;
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    background: #2563eb;
    color: #fff;
    cursor: pointer;
}

.button:hover { background: #1d4ed8; }
.button:active { transform: scale(0.97); }

/* =========================================================
   FORMS
========================================================= */
input,
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #d1d5db;
    font-size: 14px;
    background: #fff;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #2563eb;
}

/* =========================================================
   QUICK FORM (ADD OPERATION)
========================================================= */
.quick-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.quick-form select,
.quick-form input {
    min-width: 150px;
}

/* =========================================================
   BALANCE / HERO
========================================================= */
.balance-block {
    margin-top: 12px;
}

.balance-main {
    font-size: 34px;
    font-weight: 800;
    margin-bottom: 6px;
}

.balance-info {
    display: flex;
    gap: 14px;
    font-size: 14px;
    margin-bottom: 8px;
}

.daily-limit {
    font-size: 14px;
    margin-bottom: 10px;
}

.piggy-block {
    background: #f9fafb;
    border-radius: 12px;
    padding: 12px;
    font-size: 14px;
    border-left: 4px solid #22c55e;
}

.piggy-block div {
    font-weight: 600;
    margin-top: 4px;
}

/* =========================================================
   TABLE (DESKTOP)
========================================================= */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th,
td {
    padding: 12px 10px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
}

th {
    color: #6b7280;
    font-weight: 600;
}

/* =========================================================
   AUTH
========================================================= */
.auth-page {
    min-height: 100vh;
    background: #020617;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-wrapper {
    max-width: 360px;
    width: 100%;
    padding: 16px;
}

.error {
    color: #fb7185;
    text-align: center;
    margin-bottom: 12px;
}

/* =========================================================
   MOBILE (APP MODE)
========================================================= */
@media (max-width: 600px) {

    html { font-size: 17px; }
    body { background: #f5f6f8; }

    .container {
        max-width: 420px;
        padding: 0 12px;
    }

    .box {
        padding: 14px;
    }

    /* HEADER */


    /* QUICK FORM → ACTION BAR */
    .quick-form {
        display: grid;
        grid-template-columns: 44px 1fr 44px;
        gap: 8px;
        align-items: center;
    }

    .quick-form select:first-child {
        height: 44px;
        font-size: 18px;
        padding: 0;
        text-align: center;
    }

    .quick-form input[type="number"] {
        height: 44px;
        font-size: 18px;
    }

    .quick-form select:not(:first-child),
    .quick-form textarea {
        grid-column: span 3;
    }

    .quick-form .button {
        height: 44px;
        width: 44px;
        border-radius: 50%;
        padding: 0;
        font-size: 20px;
    }

    /* BALANCE HERO */
    .balance-block {
        text-align: center;
    }

    .balance-main {
        font-size: 42px;
        font-weight: 900;
        letter-spacing: -0.02em;
    }

    .balance-info {
        justify-content: center;
    }

    .daily-limit {
        opacity: 0.85;
    }

    .piggy-block {
        text-align: center;
    }

    /* TABLE → CARDS */
@media (max-width: 600px) {

    /* TABLE → CARDS (FIX) */
    table {
        width: 100%;
        border-collapse: separate;
        border-spacing: 0;
    }

    thead {
        display: none;
    }

    tbody {
        display: block;
    }

    tbody tr {
        display: block;
        background: #fff;
        border-radius: 16px;
        padding: 12px 14px;
        margin-bottom: 10px;
        box-shadow: 0 2px 8px rgba(0,0,0,.05);
    }

    tbody td {
        display: flex;
        justify-content: space-between;
        padding: 4px 0;
        border: none;
        font-size: 14px;
    }

    tbody td:first-child {
        font-weight: 600;
        font-size: 15px;
    }

    tbody td:nth-child(4) {
        font-size: 16px;
        font-weight: 700;
    }

    tbody td:last-child {
        justify-content: flex-end;
    }
}
.balance-card {
    background: #fff;
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,.06);
    margin-top: 16px;
}

/* Баланс */
.balance-total .label {
    font-size: 13px;
    color: #888;
}

.balance-total .value {
    font-size: 32px;
    font-weight: 700;
    margin-top: 4px;
}

.balance-total .value span {
    font-size: 16px;
    color: #777;
}

/* Доход / расход */
.balance-stats {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

.stat {
    flex: 1;
    background: #f7f7f7;
    border-radius: 10px;
    padding: 10px;
    font-size: 14px;
}

.stat strong {
    display: block;
    margin-top: 4px;
}

.stat.income strong { color: #2ecc71; }
.stat.expense strong { color: #e74c3c; }

/* Лимит */
.limit-row {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
    font-size: 14px;
    color: #555;
}

/* Копилка */
.piggy-card {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #eee;
}

.piggy-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
}

.piggy-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 14px;
}

.piggy-empty {
    font-size: 13px;
    color: #999;
}
.operations-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

/* Карточка операции */
.operation-card {
    background: #fff;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,.05);
}

/* Цветовая метка */
.operation-card.income {
    border-left: 4px solid #2ecc71;
}

.operation-card.expense {
    border-left: 4px solid #e74c3c;
}

/* Контент */
.op-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.op-category {
    font-size: 15px;
    font-weight: 600;
}

.op-date {
    font-size: 12px;
    color: #888;
    margin-top: 2px;
}

.op-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.op-amount {
    font-size: 16px;
    font-weight: 600;
}

.operation-card.income .op-amount {
    color: #2ecc71;
}

.operation-card.expense .op-amount {
    color: #e74c3c;
}

/* Кнопка удаления */
.op-delete {
    font-size: 18px;
    color: #bbb;
    text-decoration: none;
}

.op-delete:hover {
    color: #e74c3c;
}


    tbody tr {
        display: block;
        background: #fff;
        border-radius: 16px;
        padding: 12px 14px;
        margin-bottom: 10px;
        box-shadow: 0 2px 8px rgba(0,0,0,.05);
    }

    tbody td {
        display: flex;
        justify-content: space-between;
        padding: 4px 0;
        border: none;
        font-size: 14px;
    }

    tbody td:first-child {
        font-weight: 600;
        font-size: 15px;
    }

    tbody td:nth-child(3) {
        font-size: 16px;
    }

    tbody td:last-child {
        justify-content: flex-end;
    }
}
@media (max-width: 600px) {

    /* QUICK FORM — аккуратная сетка */
    .quick-form {
        display: grid;
        grid-template-columns: 1fr 48px;
        gap: 8px;
        align-items: center;
    }

    /* тип операции */
    .quick-form select#type {
        grid-column: span 2;
        height: 44px;
        font-size: 16px;
    }

    /* категории */
    #expenseCategories,
    #incomeCategories {
        grid-column: span 2;
        height: 44px;
        font-size: 16px;
    }

    /* сумма */
    .quick-form input[type="number"] {
        height: 48px;
        font-size: 18px;
        padding-right: 12px;
    }

    /* кнопка + */
    .quick-form .button {
        height: 48px;
        width: 48px;
        padding: 0;
        font-size: 22px;
        border-radius: 14px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}
/* =========================================================
   OPERATIONS LIST
========================================================= */

.operations-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 14px;
}

/* CARD */
.operation-card {
    background: #ffffff;
    border-radius: 14px;
    padding: 14px 16px;
    box-shadow: 0 4px 14px rgba(0,0,0,.06);
    position: relative;
    transition: transform .12s ease, box-shadow .12s ease;
}

.operation-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0,0,0,.08);
}

/* TYPE COLORS */
.operation-card.income {
    border-left: 4px solid #16a34a;
}

.operation-card.expense {
    border-left: 4px solid #dc2626;
}

/* MAIN ROW */
.op-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

/* LEFT */
.op-category {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
}

.op-date {
    font-size: 12px;
    color: #6b7280;
    margin-top: 4px;
}

/* RIGHT */
.op-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.op-amount {
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
}

.operation-card.income .op-amount {
    color: #16a34a;
}

.operation-card.expense .op-amount {
    color: #dc2626;
}

/* DELETE */
.op-delete {
    font-size: 20px;
    line-height: 1;
    color: #9ca3af;
    text-decoration: none;
    padding: 2px 4px;
    border-radius: 6px;
}

.op-delete:hover {
    color: #dc2626;
    background: #fee2e2;
}

/* EMPTY STATE */
.operations-empty {
    text-align: center;
    padding: 24px;
    color: #9ca3af;
    font-size: 14px;
}

/* =========================================================
   MOBILE POLISH
========================================================= */

@media (max-width: 600px) {

    .operation-card {
        padding: 12px 14px;
    }

    .op-category {
        font-size: 16px;
    }

    .op-amount {
        font-size: 17px;
    }

    .op-delete {
        font-size: 22px;
    }
}
/* =========================================================
   BURGER MENU
========================================================= */

.burger {
    display: none;
    width: 42px;
    height: 42px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 6px;
}

.burger span {
    display: block;
    height: 3px;
    width: 100%;
    background: #fff;
    border-radius: 2px;
    margin: 6px 0;
    transition: .3s;
}

/* MOBILE */
@media (max-width: 600px) {

    .burger {
        display: block;
    }

    .app-header nav {
        position: fixed;
        top: 64px;
        left: 0;
        width: 100%;
        background: #0f172a;
        display: flex;
        flex-direction: column;
        padding: 12px 16px;
        gap: 12px;

        transform: translateY(-120%);
        transition: transform .3s ease;
        z-index: 999;
    }

    .app-header nav.active {
        transform: translateY(0);
    }

    .app-header nav a {
        font-size: 16px;
        padding: 10px 0;
        border-bottom: 1px solid #1e293b;
    }
}

/* BURGER ANIMATION */
.burger.active span:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
}

.burger.active span:nth-child(2) {
    opacity: 0;
}

.burger.active span:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
}
/* =========================
   SETTINGS
========================= */

.page-title {
    margin-bottom: 16px;
}

.settings-card {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    max-width: 500px;
}

.settings-card h3 {
    margin-top: 0;
    margin-bottom: 16px;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.setting-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.setting-row label {
    font-size: 14px;
    color: #555;
}

.alert.success {
    background: #ecfdf5;
    color: #065f46;
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 16px;
}
/* =========================================================
   BALANCE CARD — DESKTOP LAYOUT FIX
========================================================= */

@media (min-width: 768px) {

    .balance-card {
        display: grid;
        grid-template-columns: 2fr 1fr 1fr;
        grid-template-areas:
            "total income expense"
            "limit limit limit"
            "piggy piggy piggy";
        gap: 16px;
        padding: 20px 24px;
    }

    .balance-total {
        grid-area: total;
        padding: 18px;
        background: #f8fafc;
        border-radius: 14px;
    }

    .balance-total .value {
        font-size: 36px;
        font-weight: 800;
    }

    .balance-stats {
        grid-area: income / income / expense / expense;
        display: contents;
    }

    .stat {
        padding: 16px;
        font-size: 15px;
        background: #f9fafb;
        border-radius: 14px;
        text-align: center;
    }

    .stat span {
        font-size: 13px;
        color: #6b7280;
    }

    .stat strong {
        font-size: 18px;
        margin-top: 6px;
    }

    .limit-row {
        grid-area: limit;
        background: #f1f5f9;
        border-radius: 14px;
        padding: 14px 18px;
        font-size: 15px;
    }

    .limit-row strong {
        font-size: 18px;
    }

    .piggy-card {
        grid-area: piggy;
        background: #f9fafb;
        border-radius: 14px;
        padding: 16px 18px;
    }

    .piggy-row {
        display: grid;
        grid-template-columns: 1fr auto;
        font-size: 15px;
        padding: 8px 0;
    }
}
