/* KK Cans ERP — internal tool styling.
   Palette nods to the shop floor: steel blue-grey structure, warm amber
   reserved strictly for stock warnings (matches the brazing-torch amber
   they'd recognize from the welding bay) — not used decoratively elsewhere. */

:root {
    --ink: #1c232c;
    --steel-900: #202a35;
    --steel-700: #3a4756;
    --steel-500: #5b6b7d;
    --steel-200: #dde3e9;
    --steel-100: #eef1f4;
    --bg: #f4f5f7;
    --surface: #ffffff;
    --line: #d7dde3;
    --amber: #c9791f;
    --amber-bg: #fbeddd;
    --green: #2e7d4f;
    --green-bg: #e7f4ec;
    --red: #b3402f;
    --red-bg: #fbe9e6;
    --radius: 6px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
}

/* ---------- Login page ---------- */
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--steel-900);
    background-image: linear-gradient(160deg, var(--steel-900) 0%, #131920 100%);
}

.login-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 40px 36px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.35);
}

.login-card h1 {
    font-size: 19px;
    margin: 0 0 2px;
    letter-spacing: 0.2px;
}

.login-card .sub {
    color: var(--steel-500);
    font-size: 13px;
    margin: 0 0 28px;
}

.field { margin-bottom: 16px; }

.field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--steel-700);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.field input, .field select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font);
    background: var(--surface);
}

.field input:focus, .field select:focus {
    outline: none;
    border-color: var(--steel-700);
    box-shadow: 0 0 0 3px var(--steel-200);
}

button.btn {
    cursor: pointer;
    border: none;
    border-radius: var(--radius);
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
}

.btn-primary { background: var(--steel-900); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--ink); }
.btn-secondary { background: var(--steel-100); color: var(--ink); }
.btn-secondary:hover { background: var(--steel-200); }
.btn-danger { background: var(--red-bg); color: var(--red); }

.error-banner {
    background: var(--red-bg);
    color: var(--red);
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
}

.hint {
    font-size: 12px;
    color: var(--steel-500);
    margin-top: 18px;
    line-height: 1.5;
}

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    background: var(--steel-900);
    color: #fff;
    padding: 20px 0;
    flex-shrink: 0;
}

.sidebar .brand {
    padding: 0 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 16px;
}

.sidebar .brand strong { display: block; font-size: 15px; }
.sidebar .brand span { display: block; font-size: 11px; color: var(--steel-200); margin-top: 2px; }

.nav-item {
    display: block;
    padding: 10px 20px;
    color: var(--steel-200);
    text-decoration: none;
    font-size: 13px;
    cursor: pointer;
    border-left: 3px solid transparent;
}

.nav-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav-item.active { color: #fff; border-left-color: var(--amber); background: rgba(255,255,255,0.06); }

.sidebar-footer {
    position: absolute;
    bottom: 0;
    width: 220px;
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 12px;
    color: var(--steel-200);
}
.sidebar-footer a { color: #fff; cursor: pointer; }

.main {
    flex: 1;
    padding: 28px 36px;
    max-width: 1100px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 20px;
}

.page-header h1 { font-size: 20px; margin: 0 0 4px; }
.page-header p { margin: 0; color: var(--steel-500); font-size: 13px; }

/* ---------- Toolbar / filters ---------- */
.toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.toolbar input[type=text], .toolbar select {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: var(--font);
    background: var(--surface);
}

.toolbar input[type=text] { flex: 1; min-width: 200px; }

/* ---------- Table ---------- */
.table-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

table { width: 100%; border-collapse: collapse; }

th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--steel-500);
    padding: 10px 14px;
    background: var(--steel-100);
    border-bottom: 1px solid var(--line);
}

td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--steel-100);
    font-size: 13px;
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }

.sku { font-family: var(--mono); font-size: 12px; color: var(--steel-500); }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
}

.badge-ok { background: var(--green-bg); color: var(--green); }
.badge-low { background: var(--amber-bg); color: var(--amber); }
.badge-out { background: var(--red-bg); color: var(--red); }

.link-btn {
    background: none;
    border: none;
    color: var(--steel-700);
    font-weight: 600;
    cursor: pointer;
    font-size: 13px;
    padding: 4px 8px;
}
.link-btn:hover { color: var(--ink); text-decoration: underline; }

.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--steel-500);
}

/* ---------- Modal ---------- */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(20,26,32,0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 50;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 28px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal h2 { font-size: 16px; margin: 0 0 4px; }
.modal .item-name { font-size: 13px; color: var(--steel-500); margin: 0 0 20px; }

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 22px;
}

.movement-type-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.movement-type-toggle button {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--steel-500);
}

.movement-type-toggle button.selected.in { background: var(--green-bg); color: var(--green); border-color: var(--green); }
.movement-type-toggle button.selected.out { background: var(--red-bg); color: var(--red); border-color: var(--red); }
.movement-type-toggle button.selected.adjustment { background: var(--steel-100); color: var(--steel-900); border-color: var(--steel-700); }

.stock-value { font-weight: 600; font-variant-numeric: tabular-nums; }

.movement-history { margin-top: 22px; }
.movement-history h3 { font-size: 12px; text-transform: uppercase; color: var(--steel-500); letter-spacing: 0.4px; margin-bottom: 8px; }
.movement-row { display: flex; justify-content: space-between; font-size: 12px; padding: 6px 0; border-bottom: 1px solid var(--steel-100); }
.movement-row .mv-meta { color: var(--steel-500); }

.toast {
    position: fixed;
    bottom: 24px; right: 24px;
    background: var(--ink);
    color: #fff;
    padding: 12px 18px;
    border-radius: var(--radius);
    font-size: 13px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    z-index: 100;
}
.toast.error { background: var(--red); }
