* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
body { font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; margin: 0; background: #f4f6f9; color: #1f2733; -webkit-text-size-adjust: 100%; }

/* ---------- Header / nav ---------- */
header { background: #1f3a5f; color: #fff; }
.hbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; }
header .brand { font-weight: 700; font-size: 17px; color: #fff; }
.hamburger { display: none; background: transparent; border: 1px solid rgba(255,255,255,.5); color: #fff; font-size: 20px; line-height: 1; padding: 6px 11px; border-radius: 8px; cursor: pointer; }
header nav { display: flex; align-items: center; gap: 4px; padding: 0 18px 12px; }
header nav a { color: #cfe0ff; text-decoration: none; padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
header nav a:hover { background: rgba(255,255,255,.12); }
header nav .who { margin-left: auto; color: #9fb8dd; font-size: 13px; padding: 6px 10px; }

.container { max-width: 1150px; margin: 20px auto; padding: 0 14px; width: 100%; }
.card { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 18px; margin-bottom: 18px; max-width: 100%; }
h1 { font-size: 21px; margin-top: 0; }

table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #edf1f6; font-size: 14px; vertical-align: top; word-break: break-word; }
th { background: #f7f9fc; font-weight: 600; }

input, select, textarea { width: 100%; max-width: 100%; padding: 10px 11px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 15px; font-family: inherit; }
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 5px; }

.btn { display: inline-block; background: #1f3a5f; color: #fff; border: none; padding: 10px 16px; border-radius: 8px; cursor: pointer; text-decoration: none; font-size: 14px; }
.btn.sec { background: #e2e8f0; color: #1f2733; }
.btn.danger { background: #c0392b; }
.btn.sm { padding: 6px 11px; font-size: 12px; }

.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > div { flex: 1 1 240px; min-width: 0; }

.msg { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.msg.ok { background: #e6f6ec; color: #1e6b3a; }
.msg.err { background: #fdecea; color: #a3271b; }

.login-wrap { max-width: 360px; margin: 70px auto; padding: 0 14px; }
.actions a, .actions button { margin: 2px 4px 2px 0; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: #eef2f7; display: inline-block; }
.badge.cat { background: #dbeafe; color: #1e40af; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.toolbar .grow { flex: 1 1 260px; min-width: 0; }
.toolbar .btn { flex: 0 0 auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { font-size: 12px; padding: 5px 11px; border-radius: 16px; background: #eef2f7; color: #33415c; text-decoration: none; border: 1px solid transparent; }
.chip.active { background: #1f3a5f; color: #fff; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.muted { color: #8895a7; font-size: 12px; }
.notes { max-width: 260px; white-space: pre-wrap; word-break: break-word; }

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
    .container { margin: 14px auto; }
    h1 { font-size: 19px; }

    /* Collapsible nav */
    .hamburger { display: inline-block; }
    header nav { display: none; flex-direction: column; align-items: stretch; gap: 2px; padding: 0 10px 10px; }
    header nav.open { display: flex; }
    header nav a { padding: 11px 12px; border-radius: 8px; background: rgba(255,255,255,.06); }
    header nav .who { margin-left: 0; border-top: 1px solid rgba(255,255,255,.15); margin-top: 4px; }

    /* Tables become stacked cards */
    table, thead, tbody, th, td, tr { display: block; }
    thead { display: none; }
    .table-wrap { overflow-x: visible; }
    tr { border: 1px solid #e2e8f0; border-radius: 10px; margin-bottom: 12px; padding: 4px 10px; background: #fff; }
    td { border: none; border-bottom: 1px solid #f1f4f8; padding: 9px 2px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; font-size: 14px; }
    td:last-child { border-bottom: none; }
    td::before { content: attr(data-label); font-weight: 600; color: #64748b; flex: 0 0 38%; }
    td.actions { flex-wrap: wrap; }
    td.actions::before { flex-basis: 100%; margin-bottom: 4px; }
    td .notes, td.notes { max-width: 60%; text-align: right; }
    td input, td select { flex: 1 1 55%; }
    .toolbar .grow, .toolbar > div { flex: 1 1 100%; }
    .toolbar .btn { flex: 1 1 auto; text-align: center; }
}
