@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,650&family=Source+Sans+3:wght@400;500;600;700&display=swap');

:root {
    --paper: #f3eadb;
    --paper-2: #fffaf1;
    --ink: #221c16;
    --muted: #6d6256;
    --line: #d9ccb6;
    --forest: #1e2a24;
    --forest-2: #2b3d34;
    --moss: #3f6b54;
    --copper: #c45c26;
    --warn: #9b2c1a;
    --ok: #2c6a45;
    --shadow: 0 18px 40px rgba(34, 28, 22, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: 'Source Sans 3', sans-serif;
    background: radial-gradient(1200px 500px at 10% -10%, #fff7ea 0%, var(--paper) 45%);
    color: var(--ink);
    min-height: 100vh;
}

a { color: var(--moss); text-decoration: none; }
a:hover { color: var(--copper); }
h1, h2, h3 { font-family: 'Fraunces', serif; font-weight: 650; margin: 0; }
h1 { font-size: 2.1rem; letter-spacing: -0.03em; }
h2 { font-size: 1.2rem; }

.shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--forest);
    color: #f4ece0;
    padding: 28px 22px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand { display: flex; gap: 12px; align-items: center; color: inherit; }
.brand-mark {
    width: 46px;
    height: 46px;
    border: 1px solid #c9b89a;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: 'Fraunces', serif;
    font-size: 0.62rem;
    line-height: 1.05;
    font-weight: 650;
    color: #e8d7b8;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text small { color: #b7c0b5; font-size: 0.78rem; }

.nav { display: flex; flex-direction: column; gap: 6px; }
.nav a {
    color: #d7ddd6;
    padding: 10px 12px;
    border-radius: 8px;
}
.nav a.is-active, .nav a:hover {
    background: var(--forest-2);
    color: #fff;
}

.sidebar-picker {
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: #b7c0b5;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.sidebar-picker select {
    background: var(--forest-2);
    color: #f4ece0;
    border-color: #3d5248;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
}

.sidebar-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--copper);
    color: #fffaf1 !important;
    text-align: center;
    padding: 12px 14px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1.02rem;
}
.sidebar-cta:hover {
    background: #d56a2e;
    color: #fff !important;
}
.plus-mark {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #fffaf1;
    color: var(--copper);
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1;
    flex-shrink: 0;
}
.btn-add {
    gap: 10px;
    padding: 12px 16px;
    font-size: 1.02rem;
}
.btn-add .plus-mark {
    width: 26px;
    height: 26px;
    background: #e8d7b8;
    color: var(--forest);
}

.main { padding: 36px 42px 64px; }

.page-head {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-end;
    margin-bottom: 28px;
}
.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.72rem;
    color: var(--muted);
    margin: 0 0 8px;
    font-weight: 600;
}
.lede { color: var(--muted); margin: 8px 0 0; max-width: 46rem; }
.actions { display: flex; gap: 8px; align-items: center; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    background: var(--paper-2);
    color: var(--ink);
    padding: 10px 14px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    font: inherit;
}
.btn-primary { background: var(--forest); color: #f7f1e6; border-color: var(--forest); }
.btn-primary:hover { background: var(--forest-2); color: #fff; }
.btn-danger { background: transparent; color: var(--warn); border-color: #e3c4bb; }
.link { font-weight: 600; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 22px;
}
.stat {
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px;
    box-shadow: var(--shadow);
}
.stat span { display: block; color: var(--muted); font-size: 0.82rem; margin-bottom: 8px; }
.stat strong { font-family: 'Fraunces', serif; font-size: 1.45rem; }
.stat small { display: block; margin-top: 6px; color: var(--muted); }
.stat.accent { background: #2b3d34; color: #f6efe4; border-color: #2b3d34; }
.stat.accent span, .stat.accent small { color: #c9d3cc; }

.card {
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 8px 0 0;
    box-shadow: var(--shadow);
    margin-bottom: 22px;
    overflow: hidden;
}
.card-head {
    padding: 18px 22px 10px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: baseline;
}
.card-head p { margin: 0; color: var(--muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 18px; text-align: left; border-top: 1px solid var(--line); }
th { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
tfoot th, tfoot td { background: #f7f0e4; font-weight: 700; }
.col-eur {
    background: #2b3d34;
    color: #f6efe4;
    font-weight: 700;
}
thead .col-eur { color: #c9d3cc; }
tfoot .col-eur { background: #2b3d34; color: #f6efe4; }
.right { text-align: right; }
.muted { color: var(--muted); }
.warn { color: var(--warn); font-size: 0.78rem; margin-left: 6px; }
tr.is-filled {
    background: #ece7de;
    color: #7a7368;
}
tr.is-filled a { color: #7a7368; }
tr.is-filled input {
    background: #f3eee4;
    color: #6d6256;
}
tr.is-waiting {
    background: #fffaf1;
}
tr.is-waiting .reading-status {
    color: var(--copper);
    font-weight: 700;
}
tr.is-filled .reading-status {
    color: #8a8278;
    font-weight: 600;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    padding: 18px 22px 22px;
}
.form-grid label, form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--muted);
}
.wide { grid-column: span 2; }
.form-actions-in-card {
    grid-column: 1 / -1;
    margin: 4px 0 0;
    align-items: center;
}
input, select {
    font: inherit;
    color: var(--ink);
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 10px;
    padding: 10px 12px;
}
label small, label em { font-weight: 400; }
label em, .field-error { color: var(--warn); }

.summary-bar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    background: var(--forest);
    color: #f4ece0;
    border-radius: 16px;
    padding: 16px 18px;
    margin-bottom: 18px;
}
.summary-bar span { display: block; font-size: 0.78rem; color: #c9d3cc; }
.summary-bar strong { font-family: 'Fraunces', serif; font-size: 1.3rem; }

.input-table input { width: 120px; }
.form-actions { display: flex; gap: 10px; margin: 8px 0 40px; flex-wrap: wrap; }
.form-actions-top { margin: 0; }
.field-action { display: flex; align-items: end; }
.empty {
    background: var(--paper-2);
    border: 1px dashed var(--line);
    border-radius: 18px;
    padding: 40px;
}

.flash {
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 18px;
    font-weight: 600;
}
.flash-success { background: #e5f0e6; color: var(--ok); }
.flash-error { background: #f8e4de; color: var(--warn); }

.sidebar-account {
    margin-top: auto;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding-top: 14px;
    border-top: 1px solid #3d5248;
}
.user-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    border-radius: 50%;
    background: var(--forest-2);
    color: #e8d7b8;
    overflow: hidden;
}
.user-icon svg {
    display: block;
    width: 16px;
    height: 16px;
    max-width: 16px;
    max-height: 16px;
}
.user-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #f4ece0;
    font-size: 0.92rem;
    font-weight: 600;
}
.account-menu {
    position: relative;
    margin-left: auto;
    flex-shrink: 0;
}
.account-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #c9d3cc;
    cursor: pointer;
}
.account-menu-toggle:hover,
.account-menu.is-open .account-menu-toggle {
    background: var(--forest-2);
    color: #fff;
}
.account-menu-list {
    display: none;
    position: absolute;
    right: 0;
    bottom: calc(100% + 6px);
    min-width: 188px;
    padding: 6px;
    background: #24352d;
    border: 1px solid #3d5248;
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
    z-index: 20;
}
.account-menu.is-open .account-menu-list {
    display: block;
}
.account-menu-list a,
.account-menu-list button {
    display: block;
    width: 100%;
    padding: 9px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #f4ece0;
    font: inherit;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}
.account-menu-list a:hover,
.account-menu-list button:hover {
    background: var(--forest-2);
    color: #fff;
}
.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.login-card { width: min(420px, 100%); }
.login-body { padding: 0 22px 22px; }
.login-form { padding: 0; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input { width: 140px; }

@media (max-width: 1100px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { height: auto; position: relative; }
    .stat-grid, .summary-bar, .form-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
    .main { padding: 20px; }
    .stat-grid, .summary-bar, .form-grid, .page-head { display: block; }
    .page-head .btn { margin-top: 12px; }
}
