* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    color: #1a1a2e;
    background: #f5f6fa;
}

.topbar {
    background: #1a1a2e;
    color: #fff;
    padding: 12px 24px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar .logo {
    font-weight: 600;
    font-size: 18px;
}

.topbar-nav {
    display: flex;
    gap: 18px;
    margin-left: 32px;
    margin-right: auto;
}

.topbar-nav a {
    color: #cfd2e6;
    text-decoration: none;
    font-size: 14px;
}

.topbar-nav a:hover {
    color: #fff;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.logout-form {
    margin: 0;
}

.logout-form button {
    background: transparent;
    color: #cfd2e6;
    border: 1px solid #444a6b;
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 13px;
}

.logout-form button:hover {
    background: #2a2f4a;
    color: #fff;
}

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.login-card {
    background: #fff;
    width: 100%;
    max-width: 360px;
    padding: 32px 28px;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(26, 26, 46, 0.12);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.login-card h1 {
    margin: 0;
    font-size: 22px;
    text-align: center;
}

.login-sub {
    margin: 0 0 8px;
    text-align: center;
    color: #6b6f85;
    font-size: 14px;
}

.login-card label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: #444a6b;
}

.login-card input {
    padding: 10px 12px;
    border: 1px solid #cfd2e6;
    border-radius: 8px;
    font-size: 15px;
}

.login-card input:focus {
    outline: none;
    border-color: #4a54c9;
}

.login-card button[type="submit"] {
    margin-top: 6px;
    padding: 11px;
    background: #4a54c9;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.login-card button[type="submit"]:hover {
    background: #3a44b0;
}

.login-error {
    background: #fdeaea;
    color: #b02a2a;
    border: 1px solid #f3c0c0;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    text-align: center;
}

.content {
    max-width: 1100px;
    margin: 24px auto;
    padding: 0 16px;
}

/* --- Documents page --- */
.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 36px 20px;
    margin: 16px 0 24px;
    border: 2px dashed #b8bcd8;
    border-radius: 12px;
    background: #fbfbfe;
    cursor: pointer;
    text-align: center;
    transition: border-color .15s, background .15s;
}

.dropzone:hover { border-color: #4a54c9; }

.dropzone-over {
    border-color: #4a54c9;
    background: #eef0ff;
}

.dropzone-title { font-size: 16px; font-weight: 600; }
.dropzone-hint { font-size: 13px; color: #6b6f85; }
.dropzone-file { font-size: 13px; color: #4a54c9; }

.msg {
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 14px;
}
.msg-ok   { background: #e8f6ec; color: #1f7a3d; border: 1px solid #b6e2c4; }
.msg-warn { background: #fdf4e3; color: #8a6100; border: 1px solid #f0d9a6; }
.msg-error{ background: #fdeaea; color: #b02a2a; border: 1px solid #f3c0c0; }

.docs-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(26,26,46,.06);
}

.docs-table th, .docs-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid #eef0f5;
    font-size: 14px;
}

.docs-table th {
    background: #f5f6fa;
    font-weight: 600;
    color: #444a6b;
}

.docs-table tr:last-child td { border-bottom: none; }
.doc-name { font-weight: 500; }

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    background: #eef0ff;
    color: #4a54c9;
    font-size: 12px;
}

.docs-empty {
    text-align: center;
    color: #9095a8;
    padding: 24px;
}

/* --- Review screen --- */
.review-head { display: flex; align-items: baseline; gap: 12px; }
.review-file { color: #6b6f85; font-size: 14px; }
.msg-warn ul { margin: 6px 0 0; padding-left: 20px; }

.review-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 900px) {
    .review-grid { grid-template-columns: 1fr; }
}

.review-preview pre {
    background: #1a1a2e;
    color: #d6d9ee;
    padding: 14px;
    border-radius: 10px;
    font-size: 12px;
    line-height: 1.5;
    max-height: 640px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.review-fields h2 { margin-top: 0; }
.review-fields h3 { margin: 18px 0 8px; font-size: 15px; color: #444a6b; }

.review-fields form { display: flex; flex-direction: column; gap: 10px; }
.review-fields label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: #444a6b; }
.review-fields input, .review-fields select {
    padding: 8px 10px;
    border: 1px solid #cfd2e6;
    border-radius: 8px;
    font-size: 14px;
}
.field-row { display: flex; gap: 12px; }
.field-row label { flex: 1; }

.btn-primary {
    margin-top: 14px;
    padding: 11px;
    background: #4a54c9;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}
.btn-primary:hover { background: #3a44b0; }
.btn-cancel {
    text-align: center;
    padding: 9px;
    color: #6b6f85;
    text-decoration: none;
    font-size: 14px;
}
.items-table { margin-top: 8px; }
.items-table td { font-size: 13px; }
.review-hint { font-size: 12px; color: #9095a8; margin-top: 8px; }
.doc-actions a { margin-right: 12px; }

/* --- Filters + editable items --- */
.filters {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 14px 0 20px;
    flex-wrap: wrap;
}
.filters input, .filters select {
    padding: 8px 10px;
    border: 1px solid #cfd2e6;
    border-radius: 8px;
    font-size: 14px;
}
.filters input[name="q"] { min-width: 240px; }
.filters button {
    padding: 8px 16px;
    background: #4a54c9;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}
.filters-reset { font-size: 13px; color: #6b6f85; }
.num, .cell-num { text-align: right; }
.badge-dup { background: #fdeaea; color: #b02a2a; }

.items-edit input {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 8px;
    border: 1px solid #dfe2ef;
    border-radius: 6px;
    font-size: 13px;
}
.items-edit .cell-num input { text-align: right; max-width: 110px; }
.items-edit td { padding: 6px 6px; }

/* --- Expense items page --- */
.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    align-items: start;
}
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.inline-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
}
.inline-form input, .inline-form select {
    padding: 8px 10px;
    border: 1px solid #cfd2e6;
    border-radius: 8px;
    font-size: 14px;
}
.inline-form input[name="name"], .inline-form input[name="pattern"] { min-width: 220px; }
.inline-form button {
    padding: 8px 16px;
    background: #4a54c9;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}
.rules-title { margin-top: 0; }

/* --- Status badges + row actions --- */
.badge-ok   { background: #e8f6ec; color: #1f7a3d; }
.badge-wait { background: #fdf4e3; color: #8a6100; }
.row-action { display: inline; margin: 0 4px 0 0; }
.row-action button {
    background: transparent;
    border: 1px solid #cfd2e6;
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 12px;
    cursor: pointer;
    color: #444a6b;
}
.row-action button:hover { background: #eef0ff; }
.row-action .act-ok { border-color: #b6e2c4; color: #1f7a3d; }
.row-action .act-no { border-color: #f3c0c0; color: #b02a2a; }

/* --- Calendar + payables --- */
.calendar-total { font-size: 15px; }
.cal-overdue-title { color: #b02a2a; }
.row-overdue td { background: #fdf1f1; }
.debt-pos { color: #b02a2a; font-weight: 600; }
.pay-form { display: flex; gap: 6px; }
.pay-form input {
    padding: 4px 8px;
    border: 1px solid #cfd2e6;
    border-radius: 6px;
    font-size: 12px;
    width: 90px;
    text-align: right;
}
.pay-form button {
    background: #4a54c9;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
}

/* --- Dashboard --- */
.dash-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.dash-month { margin: 0; }
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin: 18px 0 26px;
}
.card {
    background: #fff;
    border-radius: 12px;
    padding: 18px 20px;
    box-shadow: 0 1px 4px rgba(26,26,46,.06);
}
.card-value { font-size: 22px; font-weight: 700; }
.card-label { font-size: 13px; color: #6b6f85; margin-top: 4px; }
.card-alert { border: 1px solid #f3c0c0; }
.card-alert .card-value { color: #b02a2a; }

.bar-row {
    display: grid;
    grid-template-columns: 160px 1fr 110px;
    gap: 10px;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
}
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: #eef0f5; border-radius: 6px; height: 18px; }
.bar-fill { background: #4a54c9; height: 100%; border-radius: 6px; min-width: 2px; }
.bar-cash { background: #1f7a3d; }
.bar-value { text-align: right; }

/* --- Audit log page --- */
.audit-details {
    font-size: 12px;
    color: #667;
    max-width: 420px;
    word-break: break-all;
}
.pager { display: flex; gap: 18px; margin: 14px 0; }
