/* =========================================
   Expense Manager
   BayStars-inspired FINAL theme
   strong desktop + refined mobile
   ========================================= */

:root {
    --bg-top: #0f2f8f;
    --bg-mid: #1b4fd6;
    --bg-bottom: #eef4ff;

    --surface: #ffffff;
    --surface-soft: #f5f8ff;
    --surface-deep: #eaf0ff;

    --primary: #1f5eff;
    --primary-strong: #0047ff;
    --primary-dark: #0a1f66;
    --primary-deep: #091742;
    --primary-soft: #e8efff;

    --text: #1f2a44;
    --text-strong: #0d1b3d;
    --text-soft: #61708f;
    --text-on-dark: #ffffff;

    --border: #d7e1f5;
    --border-strong: #bccbeb;

    --success-bg: #eaf7ef;
    --success-text: #157347;

    --danger-bg: #fff1f2;
    --danger-text: #b42318;

    --shadow-lg: 0 18px 48px rgba(8, 21, 58, 0.16);
    --shadow-md: 0 12px 28px rgba(8, 21, 58, 0.12);
    --shadow-sm: 0 6px 18px rgba(8, 21, 58, 0.08);

    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius-md: 18px;
    --radius-sm: 14px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Hiragino Sans",
        "Hiragino Kaku Gothic ProN",
        "Yu Gothic",
        Meiryo,
        sans-serif;
    color: var(--text);
    line-height: 1.6;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.18), transparent 18%),
        radial-gradient(circle at top right, rgba(255, 255, 255, 0.10), transparent 14%),
        linear-gradient(180deg, var(--bg-top) 0px, var(--bg-mid) 180px, var(--bg-bottom) 520px, #edf3ff 100%);
}

a {
    color: var(--primary-dark);
    text-decoration: none;
}

a:hover {
    opacity: 0.92;
}

img {
    max-width: 100%;
    display: block;
}

.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 22px 56px;
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 18px;
}

.brand-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 16px;
    border-radius: 999px;
    background: linear-gradient(180deg, #ffffff 0%, #edf3ff 100%);
    color: var(--primary-strong);
    font-size: 14px;
    font-weight: 900;
    letter-spacing: 0.02em;
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: 0 8px 20px rgba(9, 23, 66, 0.12);
}

.page-title {
    margin: 14px 0 6px;
    font-size: 58px;
    line-height: 1.04;
    letter-spacing: -0.03em;
    color: #ffffff;
    font-weight: 900;
    text-shadow: 0 3px 14px rgba(9, 23, 66, 0.20);
}

.page-subtitle {
    margin: 0;
    font-size: 19px;
    color: rgba(255, 255, 255, 0.92);
    font-weight: 700;
}

.user-chip {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 18px;
    border-radius: 999px;
    background: linear-gradient(180deg, #ffffff 0%, #eef3ff 100%);
    color: var(--primary-dark);
    font-size: 16px;
    font-weight: 900;
    border: 1px solid rgba(255, 255, 255, 0.74);
    box-shadow: 0 10px 24px rgba(9, 23, 66, 0.14);
}

.nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
}

.nav-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    padding: 0 18px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.78);
    background: rgba(255, 255, 255, 0.95);
    color: var(--text-strong);
    font-size: 16px;
    font-weight: 900;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(4px);
}

.nav-links a.secondary {
    background: rgba(255, 255, 255, 0.92);
}

.nav-links a:hover {
    transform: translateY(-1px);
    transition: 0.18s ease;
}

.card {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(195, 209, 241, 0.92);
    border-radius: var(--radius-xl);
    padding: 26px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(7px);
}

.card + .card {
    margin-top: 20px;
}

.message {
    margin-bottom: 18px;
    padding: 15px 16px;
    border-radius: 18px;
    background: linear-gradient(180deg, #eef5ff 0%, #dfeaff 100%);
    color: var(--primary-dark);
    font-weight: 900;
    border: 1px solid #d5e1ff;
}

.empty {
    padding: 18px 16px;
    border-radius: 18px;
    background: #f8fbff;
    border: 1px dashed var(--border-strong);
    color: var(--text-soft);
    font-weight: 800;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field label {
    font-size: 15px;
    font-weight: 900;
    color: var(--primary-deep);
}

.field input[type="text"],
.field input[type="date"],
.field input[type="password"],
.field input[type="file"],
.field select,
.field textarea {
    width: 100%;
    border: 2px solid #d8e2f6;
    background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
    color: var(--text);
    border-radius: 18px;
    padding: 15px 16px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease, background 0.18s ease;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.field input[type="text"]:focus,
.field input[type="date"]:focus,
.field input[type="password"]:focus,
.field input[type="file"]:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 5px rgba(31, 94, 255, 0.13);
    background: #ffffff;
}

.field input[readonly] {
    background: #f4f8ff;
    color: var(--text-strong);
}

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

.note {
    font-size: 13px;
    color: var(--text-soft);
    font-weight: 700;
}

.preview-box {
    margin-top: 6px;
}

.thumb-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 14px;
    border: 1px solid #ced9f3;
    background: linear-gradient(180deg, #ffffff 0%, #f7faff 100%);
    color: var(--primary-dark);
    font-weight: 900;
    box-shadow: 0 4px 12px rgba(8, 21, 58, 0.05);
}

.small {
    font-size: 13px;
    color: var(--text-soft);
    font-weight: 800;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.actions > * {
    margin: 0 !important;
}

.actions:last-child {
    grid-column: 1 / -1;
}

button,
.button,
a.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    padding: 0 22px;
    border: none;
    border-radius: 18px;
    background: linear-gradient(180deg, #2568ff 0%, #0047ff 100%);
    color: #ffffff;
    text-decoration: none;
    font-size: 17px;
    font-weight: 900;
    line-height: 1;
    cursor: pointer;
    box-shadow:
        0 16px 30px rgba(0, 71, 255, 0.24),
        inset 0 -1px 0 rgba(0, 0, 0, 0.10);
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

button:hover,
.button:hover,
a.button:hover {
    transform: translateY(-1px);
    box-shadow:
        0 18px 34px rgba(0, 71, 255, 0.26),
        inset 0 -1px 0 rgba(0, 0, 0, 0.10);
    opacity: 1;
}

button.secondary,
.button.secondary,
a.button.secondary {
    background: linear-gradient(180deg, #ffffff 0%, #f4f8ff 100%);
    color: var(--primary-deep);
    border: 1px solid #cad7f3;
    box-shadow: 0 6px 14px rgba(8, 21, 58, 0.06);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.summary-box {
    background:
        linear-gradient(135deg, rgba(31, 94, 255, 0.08) 0%, rgba(255, 255, 255, 0.96) 48%),
        linear-gradient(180deg, #ffffff 0%, #f4f8ff 100%);
    border: 1px solid #ced9f4;
    border-radius: 24px;
    padding: 22px 22px;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.summary-box::after {
    content: "";
    position: absolute;
    right: -18px;
    top: -18px;
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: rgba(31, 94, 255, 0.10);
}

.summary-label {
    position: relative;
    z-index: 1;
    font-size: 14px;
    color: var(--text-soft);
    margin-bottom: 10px;
    font-weight: 800;
}

.summary-value {
    position: relative;
    z-index: 1;
    font-size: 30px;
    font-weight: 900;
    line-height: 1.2;
    color: var(--primary-dark);
    letter-spacing: -0.02em;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.desktop-table {
    display: block;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
    min-width: 980px;
}

thead th {
    text-align: left;
    padding: 16px 12px;
    font-size: 14px;
    font-weight: 900;
    color: var(--primary-deep);
    background: linear-gradient(180deg, #f4f8ff 0%, #ebf1ff 100%);
    border-bottom: 1px solid #d4def5;
    white-space: nowrap;
}

tbody td {
    padding: 16px 12px;
    font-size: 15px;
    color: var(--text);
    border-bottom: 1px solid #e3eaf7;
    vertical-align: top;
    background: rgba(255, 255, 255, 0.70);
}

tbody tr:hover td {
    background: rgba(232, 239, 255, 0.82);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    background: linear-gradient(180deg, #eaf0ff 0%, #dae6ff 100%);
    color: var(--primary-dark);
    font-size: 14px;
    font-weight: 900;
    border: 1px solid rgba(31, 94, 255, 0.10);
}

.mobile-cards {
    display: none;
}

.expense-card {
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    border: 1px solid #d5def3;
    border-radius: 24px;
    padding: 18px;
    box-shadow: var(--shadow-md);
}

.expense-card + .expense-card {
    margin-top: 14px;
}

.expense-card .title {
    margin-bottom: 14px;
    font-size: 21px;
    font-weight: 900;
    color: var(--primary-dark);
    line-height: 1.3;
}

.expense-meta {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 8px 12px;
    margin-bottom: 16px;
}

.expense-meta .label {
    color: var(--text-soft);
    font-size: 14px;
    font-weight: 800;
}

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

input[type="file"] {
    padding: 11px 12px;
    background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

form[style*="margin:0"] {
    display: inline;
}

/* =========================
   tablet
   ========================= */
@media (max-width: 980px) {
    .page {
        padding: 22px 16px 42px;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .page-title {
        font-size: 46px;
        line-height: 1.08;
        margin-top: 12px;
    }

    .page-subtitle {
        font-size: 17px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }

    .desktop-table {
        display: none;
    }

    .mobile-cards {
        display: block;
    }

    .user-chip {
        align-self: flex-start;
    }
}

/* =========================
   mobile final tuning
   ========================= */
@media (max-width: 640px) {
    html,
    body {
        background:
            linear-gradient(180deg, #163ba8 0px, #2b5fe0 150px, #eef4ff 420px, #eef4ff 100%);
    }

    .page {
        padding: 14px 14px 30px;
    }

    .topbar {
        gap: 12px;
        margin-bottom: 14px;
    }

    .brand-badge {
        min-height: 32px;
        padding: 0 14px;
        font-size: 13px;
    }

    .page-title {
        font-size: 33px;
        line-height: 1.08;
        margin: 10px 0 6px;
        letter-spacing: -0.025em;
        text-shadow: 0 2px 10px rgba(9, 23, 66, 0.18);
    }

    .page-subtitle {
        font-size: 15px;
        line-height: 1.5;
        color: rgba(255, 255, 255, 0.94);
    }

    .user-chip {
        min-height: 40px;
        padding: 0 14px;
        font-size: 14px;
        box-shadow: 0 8px 18px rgba(9, 23, 66, 0.12);
    }

    .nav-links {
        gap: 10px;
        margin-bottom: 16px;
    }

    .nav-links a {
        min-height: 46px;
        padding: 0 14px;
        font-size: 15px;
        border-radius: 14px;
    }

    .card {
        padding: 16px;
        border-radius: 22px;
        box-shadow: 0 14px 30px rgba(8, 21, 58, 0.12);
    }

    .message {
        padding: 13px 14px;
        border-radius: 16px;
        font-size: 14px;
        line-height: 1.5;
    }

    .field {
        gap: 7px;
    }

    .field label {
        font-size: 14px;
    }

    .field input[type="text"],
    .field input[type="date"],
    .field input[type="password"],
    .field input[type="file"],
    .field select,
    .field textarea {
        font-size: 16px;
        padding: 13px 14px;
        border-radius: 16px;
    }

    .field textarea {
        min-height: 110px;
    }

    .note {
        font-size: 12px;
        line-height: 1.55;
    }

    button,
    .button,
    a.button {
        width: 100%;
        min-height: 52px;
        font-size: 16px;
        border-radius: 16px;
    }

    .actions {
        width: 100%;
        gap: 10px;
    }

    .actions > form {
        width: 100%;
    }

    .summary-box {
        padding: 18px 18px;
        border-radius: 20px;
    }

    .summary-label {
        font-size: 13px;
        margin-bottom: 8px;
    }

    .summary-value {
        font-size: 24px;
    }

    .expense-card {
        border-radius: 20px;
        padding: 16px;
    }

    .expense-card .title {
        font-size: 19px;
        margin-bottom: 12px;
    }

    .expense-meta {
        grid-template-columns: 92px 1fr;
        gap: 7px 10px;
    }

    .expense-meta .label {
        font-size: 13px;
    }

    .thumb-link {
        width: 100%;
        min-height: 42px;
        border-radius: 13px;
    }
}