* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Segoe UI", Arial, sans-serif;
    background: #f4f6f8;
    color: #1f2937;
}
a { color: #1d4ed8; text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    background: #0f172a;
    color: #fff;
}
.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}
.brand { color: #fff; font-size: 20px; font-weight: 600; }
.brand span { color: #93c5fd; font-weight: 400; }
.topbar nav a {
    color: #cbd5e1;
    margin-left: 18px;
    font-size: 15px;
    padding: 6px 4px;
}
.topbar nav a:hover, .topbar nav a.active {
    color: #fff;
    border-bottom: 2px solid #3b82f6;
    text-decoration: none;
}

.page {
    max-width: 1100px;
    margin: 24px auto;
    padding: 0 20px 40px;
}

.flash {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 18px;
    font-size: 15px;
}
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.flash-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    padding: 20px 24px;
    margin-bottom: 20px;
}

h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 0 0 12px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid #e5e7eb; font-size: 14px; }
th { background: #f8fafc; font-weight: 600; color: #475569; }
tr:hover td { background: #f8fafc; }

.btn {
    display: inline-block;
    padding: 9px 18px;
    border-radius: 6px;
    border: none;
    background: #1d4ed8;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
}
.btn:hover { background: #1e40af; text-decoration: none; }
.btn-secondary { background: #64748b; }
.btn-secondary:hover { background: #475569; }
.btn-danger { background: #dc2626; }
.btn-danger:hover { background: #b91c1c; }
.btn-small { padding: 5px 12px; font-size: 13px; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px 20px;
}
.form-group { display: flex; flex-direction: column; margin-bottom: 4px; }
.form-group label { font-size: 13px; font-weight: 600; color: #475569; margin-bottom: 5px; }
.form-group input, .form-group select, .form-group textarea {
    padding: 9px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
}
.hint { font-size: 12px; color: #64748b; margin-top: 4px; }

.items-table th, .items-table td { text-align: right; }
.items-table th:nth-child(2), .items-table td:nth-child(2),
.items-table th:nth-child(3), .items-table td:nth-child(3) { text-align: left; }
.items-table input { width: 100%; border: 1px solid #cbd5e1; border-radius: 4px; padding: 6px; font-size: 13px; text-align: right; }
.items-table input.text-left { text-align: left; }

.totals-box { max-width: 360px; margin-left: auto; margin-top: 16px; }
.totals-box .row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 14px; }
.totals-box .row.total { font-weight: 700; font-size: 17px; border-top: 2px solid #1f2937; padding-top: 10px; margin-top: 6px; }

.autocomplete-wrap { position: relative; }
.autocomplete-list {
    position: absolute;
    top: 100%; left: 0; right: 0;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 220px;
    overflow-y: auto;
    z-index: 20;
    box-shadow: 0 4px 8px rgba(0,0,0,0.08);
}
.autocomplete-list div { padding: 8px 10px; cursor: pointer; font-size: 13px; }
.autocomplete-list div:hover { background: #eff6ff; }

.status-issued { color: #166534; font-weight: 600; }
.status-void { color: #991b1b; font-weight: 600; text-decoration: line-through; }

.stat-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.stat-box { flex: 1; min-width: 160px; background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); padding: 16px 20px; }
.stat-box .num { font-size: 26px; font-weight: 700; color: #0f172a; }
.stat-box .label { font-size: 13px; color: #64748b; margin-top: 4px; }

.month-group {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    margin-bottom: 12px;
    overflow: hidden;
    background: #fff;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.month-group:hover { border-color: #cbd5e1; box-shadow: 0 2px 8px rgba(15,23,42,0.06); }
.month-group summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    color: #1e293b;
    list-style: none;
}
.month-group summary::-webkit-details-marker { display: none; }
.month-group .month-actions { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.month-group .chevron {
    display: inline-flex;
    color: #1d4ed8;
    transition: transform 0.15s ease;
    line-height: 0;
}
.month-group[open] .chevron { transform: rotate(180deg); }
.month-group[open] summary { border-bottom: 1px solid #e2e8f0; }
.month-group table { margin: 0; }
.month-group table th, .month-group table td { padding: 10px 20px; }

.footer { text-align: center; color: #94a3b8; font-size: 13px; padding: 20px; }

@media (max-width: 700px) {
    .form-grid { grid-template-columns: 1fr; }
}
