:root {
    --bg: #f4f7fb;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --brand: #2563eb;
    --brand-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --border: #dbe3ef;
    --shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}
.app-shell { min-height: 100vh; }
.topbar {
    background: linear-gradient(135deg, var(--brand), #0ea5e9);
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.topbar h1 { margin: 0 0 4px; font-size: 22px; }
.userbox { text-align: right; display: grid; gap: 2px; }
.nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 10px 14px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}
.nav a {
    text-decoration: none;
    color: var(--brand);
    background: #eff6ff;
    padding: 10px 12px;
    border-radius: 10px;
    white-space: nowrap;
    font-weight: 600;
}
.container { padding: 18px; max-width: 1280px; margin: 0 auto; }
.card {
    background: var(--card);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 18px;
}
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
label { font-weight: 700; font-size: 14px; }
input, select, textarea, button {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 11px 12px;
    font-size: 14px;
    background: #fff;
}
textarea { min-height: 90px; resize: vertical; }
button, .btn {
    background: var(--brand);
    color: #fff;
    border: 0;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    font-weight: 700;
}
button:hover, .btn:hover { background: var(--brand-dark); }
.btn-secondary { background: #475569; }
.btn-success { background: var(--success); }
.btn-danger { background: var(--danger); }
.btn-outline {
    background: #fff;
    color: var(--brand);
    border: 1px solid var(--brand);
}
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}
th, td {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
    font-size: 14px;
}
th { background: #f8fafc; }
.kpi {
    display: grid;
    gap: 6px;
    background: #fff;
    border-radius: 16px;
    padding: 16px;
    box-shadow: var(--shadow);
}
.kpi .value { font-size: 28px; font-weight: 800; }
.kpi small { color: var(--muted); }
.alert {
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 14px;
    font-weight: 700;
}
.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #ffedd5; color: #9a3412; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 440px; }
.stepper {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
    margin-bottom: 16px;
}
.stepper .step {
    text-align: center;
    font-size: 12px;
    padding: 8px 6px;
    border-radius: 10px;
    background: #e2e8f0;
    font-weight: 700;
}
.stepper .step.active, .stepper .step.done { background: #bfdbfe; color: #1d4ed8; }
.form-step { display: none; }
.form-step.active { display: block; }
.signature-box {
    border: 1px dashed #94a3b8;
    border-radius: 14px;
    background: #fff;
    padding: 12px;
    position: relative;
}
.signature-box h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.signature-status {
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    background: #fee2e2;
    color: #ef4444;
}
.signature-pad {
    width: 100%;
    height: 180px;
    background: #ffffff;
    border: 2px solid var(--border);
    border-radius: 12px;
    touch-action: none;
    cursor: crosshair;
    display: block;
}
.signature-pad:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.inline-note { color: var(--muted); font-size: 12px; }
.badge {
    display: inline-block;
    padding: 5px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: #e2e8f0;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #ffedd5; color: #9a3412; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.repeatable-row {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(6, minmax(0,1fr)) auto;
    align-items: end;
    margin-bottom: 10px;
}
.repeatable-row.stock { grid-template-columns: repeat(6, minmax(0,1fr)) auto; }
.repeatable-row.issue { grid-template-columns: 1fr 2fr 1fr auto; }
.repeatable-row.follow { grid-template-columns: 1.5fr 1fr 1fr auto; }
hr.soft { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.text-right { text-align: right; }
@media (max-width: 920px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .repeatable-row, .repeatable-row.stock, .repeatable-row.issue, .repeatable-row.follow { grid-template-columns: 1fr; }
    .stepper { grid-template-columns: repeat(4, 1fr); }
    .topbar { align-items: flex-start; flex-direction: column; }
}
