:root {
    --brand-black:     #000000;
    --brand-accent:    #A82400;
    --brand-accent-dark: #7A1A00;
    --brand-accent-soft: #F7E5DF;
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f6f9;
    margin: 0;
    color: #1a1a1a;
}

/* ── Header / nav ───────────────────────────────────────────── */
.topbar {
    background: #fff;
    border-bottom: 3px solid var(--brand-accent);
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brand {
    display: flex;
    align-items: center;
    text-decoration: none;
}
.brand-logo {
    height: 34px;
    display: block;
}
.nav {
    display: flex;
    gap: 6px;
}
.nav-link {
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--brand-black);
    font-weight: 600;
    font-size: 0.92em;
    transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--brand-accent-soft); }
.nav-link.active { background: var(--brand-accent); color: #fff; }

/* ── Layout ──────────────────────────────────────────────────── */
.page { padding: 20px; }
.container {
    max-width: 650px;
    background: white;
    margin: 20px auto;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.container.wide { max-width: 900px; }

h2 { margin-top: 0; border-bottom: 2px solid var(--brand-accent); padding-bottom: 10px; color: var(--brand-black); }
h3 { color: var(--brand-black); }

.form-group { margin-bottom: 16px; display: flex; flex-direction: column; }
label { font-weight: bold; margin-bottom: 6px; font-size: 0.85em; color: #444; text-transform: uppercase; letter-spacing: 0.03em; }

input, select {
    box-sizing: border-box;
    width: 100%;
    height: 44px;
    padding: 0 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1em;
    font-family: inherit;
    background: #fff;
    color: #1a1a1a;
}
input::placeholder { color: #999; }
input:focus, select:focus {
    outline: none;
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 3px var(--brand-accent-soft);
}

select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%23555' stroke-width='1.6' fill='none' fill-rule='evenodd'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

input[type="date"] { padding-right: 8px; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }

button {
    background: var(--brand-accent); color: white; padding: 12px; border: none; border-radius: 4px;
    font-size: 1em; font-weight: bold; cursor: pointer; transition: background 0.2s;
    margin-top: 10px; width: 100%;
}
button:hover { background: var(--brand-accent-dark); }
button:disabled { background: #f3b8a3; cursor: not-allowed; }

.form-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 2px solid var(--brand-accent); padding-bottom: 10px; margin-bottom: 16px; }
.form-header h2 { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }

button.btn-secondary {
    background: #fff; color: var(--brand-accent); border: 1px solid var(--brand-accent);
    width: auto; margin-top: 0; padding: 8px 16px; font-size: 0.9em;
}
button.btn-secondary:hover { background: var(--brand-accent-soft); }

.result-box { margin-top: 25px; padding: 20px; border-radius: 6px; display: none; }
.success { background-color: #eafaf0; border: 1px solid #b8e8c8; color: #14532d; }
.error { background-color: var(--brand-accent-soft); border: 1px solid #f6c3b3; color: #8a2400; }
.usi-display { font-size: 1.5em; font-weight: bold; letter-spacing: 2px; margin: 10px 0; color: var(--brand-black); }
.loader { display: none; text-align: center; font-weight: bold; color: #666; margin: 15px 0; }

.template-link {
    display: inline-block; margin-bottom: 15px; color: var(--brand-accent); font-weight: bold; text-decoration: none;
}
.template-link:hover { color: var(--brand-accent-dark); text-decoration: underline; }

.table-scroll { max-height: 360px; overflow: auto; border: 1px solid #e1e4e8; border-radius: 6px; margin-top: 10px; }
table { width: 100%; border-collapse: collapse; }
thead th {
    text-align: left; padding: 8px; background: #f4f6f9; border-bottom: 2px solid var(--brand-accent);
    position: sticky; top: 0;
}
tbody td { padding: 8px; border-bottom: 1px solid #eee; font-size: 0.9em; }

.status-success { color: #14532d; font-weight: bold; }
.status-error { color: #8a2400; font-weight: bold; }

.muted { color: #555; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 640px) {
    .topbar-inner { padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
    .brand-logo { height: 28px; }
    .nav { gap: 2px; flex-wrap: wrap; }
    .nav-link { padding: 6px 10px; font-size: 0.85em; }

    .page { padding: 12px; }
    .container, .container.wide { max-width: 100%; margin: 12px auto; padding: 18px; border-radius: 6px; }

    .row { grid-template-columns: 1fr; gap: 0; }

    .form-header { flex-wrap: wrap; align-items: flex-start; }
    .form-header h2 { font-size: 1.2em; }
    button.btn-secondary { width: 100%; }

    h2 { font-size: 1.2em; }

    table { min-width: 560px; }
    thead th, tbody td { padding: 6px; font-size: 0.85em; }
}

@media (max-width: 400px) {
    .nav-link { padding: 5px 8px; font-size: 0.8em; }
}
