:root {
    --navy-950: #0a2239;
    --navy-900: #102f4f;
    --navy-800: #174568;
    --cyan-700: #077d91;
    --cyan-600: #0891a8;
    --cyan-500: #06a8bf;
    --cyan-100: #dff7fa;
    --surface: #fff;
    --canvas: #f3f6f9;
    --line: #dfe7ee;
    --text: #172b3a;
    --muted: #64788a;
    --success: #16845b;
    --warning: #b7791f;
    --danger: #c43d4b;
    --sidebar: 268px;
    font-family: "Cairo", "Segoe UI", Tahoma, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--canvas); color: var(--text); }
a { color: inherit; text-decoration: none; }
a.text-link { color: var(--cyan-700); text-decoration: underline; font-weight: 700; }
a.text-link:hover { color: var(--cyan-600); }
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar);
    background: linear-gradient(180deg, var(--navy-950), var(--navy-900));
    color: #fff;
    padding: 18px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: auto;
}
.brand { font-weight: 800; font-size: 18px; margin-bottom: 18px; }
.nav-sec { margin: 14px 0 6px; color: #9fb3c4; font-size: 12px; }
.nav a, .nav summary {
    display: block; padding: 8px 10px; border-radius: 8px; color: #e8f0f6;
}
.nav a:hover, .nav a.active, .nav summary:hover { background: rgba(6,168,191,.2); }
.nav details { margin-bottom: 4px; }
.nav details a { padding-right: 18px; font-size: 14px; }
.main { flex: 1; padding: 22px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; box-shadow: 0 8px 24px rgba(10,34,57,.06); }
.btn { border: 0; border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 700; }
.btn-primary { background: var(--cyan-600); color: #fff; }
.btn-secondary { background: #e8eef3; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-link { background: none; color: var(--cyan-700); padding: 0; }
.btn-compact {
    padding: 6px 12px;
    font-size: 13px;
    white-space: nowrap;
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: right; font-size: 14px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--cyan-100); }
.badge-ok { background: #e7f6ef; color: var(--success); }
.badge-warn { background: #fff3cd; color: #856404; }
tr.is-shortage td { background: #fdecef; }
.chip { background: #fff3cd; color: #856404; border-radius: 999px; padding: 2px 8px; font-size: 12px; }
.flash { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; white-space: pre-line; }
.flash-ok { background: #e7f6ef; color: var(--success); }
.flash-err { background: #fdecef; color: var(--danger); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
    width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.list-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
    margin-bottom: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
}
.list-search { flex: 1; min-width: 240px; }
.list-per-page { width: 140px; }
.list-toolbar .btn { height: 38px; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; }
.login-card { width: 380px; }
.pager {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    list-style: none;
}
.pager-btn {
    min-width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    font-weight: 700;
    font-size: 13px;
}
a.pager-btn:hover { background: var(--cyan-100); border-color: var(--cyan-600); color: var(--cyan-700); }
.pager-btn.is-active {
    background: var(--cyan-600);
    color: #fff;
    border-color: var(--cyan-600);
}
.pager-btn.is-disabled { opacity: .4; cursor: default; }
.pager-dots { color: var(--muted); padding: 0 4px; }
.pager-meta { margin-inline-start: 8px; color: var(--muted); font-size: 13px; }
.field-hint { display: block; font-size: 12px; color: var(--muted); margin-top: 6px; }
.field-row { display: flex; gap: 8px; align-items: center; }
.field-row input { flex: 1; }
.order-total-preview { grid-column: 1 / -1; margin: 0; font-size: 15px; }
.line-subtotal { white-space: nowrap; font-weight: 700; }
.totals-box {
    margin: 14px 0;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f8fbfd;
    display: grid;
    gap: 8px;
    max-width: 420px;
}
.totals-grand { font-size: 16px; }
.js-numeric { direction: ltr; text-align: right; }
.product-picker { position: relative; min-width: 260px; }
.product-results {
    position: absolute;
    inset-inline: 0;
    top: calc(100% + 4px);
    z-index: 30;
    max-height: 260px;
    overflow: auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(10,34,57,.12);
}
.product-option {
    display: flex;
    gap: 10px;
    width: 100%;
    border: 0;
    background: none;
    text-align: right;
    padding: 8px 10px;
    cursor: pointer;
    font: inherit;
}
.product-option:hover, .product-option.is-active { background: var(--cyan-100); }
.product-code { font-weight: 800; color: var(--cyan-700); min-width: 88px; }
.product-empty { padding: 10px; color: var(--muted); font-size: 13px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; white-space: nowrap; }
.row-actions form { margin: 0; }
.icon-btn {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--navy-800);
    cursor: pointer;
    padding: 0;
}
.icon-btn:hover { background: var(--cyan-100); color: var(--cyan-700); }
.icon-btn-danger:hover { background: #fdecef; color: var(--danger); }
.rate-input { display: none; }
tr.is-editing .rate-text,
tr.is-editing .rate-edit,
tr.is-editing .rate-delete { display: none; }
tr.is-inactive .rate-text { color: var(--muted); }
tr.is-editing .rate-input,
tr.is-editing .rate-save,
tr.is-editing .rate-cancel { display: inline-flex; }
tr.is-editing .rate-input { display: block; width: 100%; }
.rate-save, .rate-cancel { display: none; }
.rate-create { margin-bottom: 14px; }
.rate-create-actions { display: flex; gap: 8px; align-items: end; }
.rate-create-actions .btn { height: 38px; }
@media (max-width: 900px) {
    .app { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: relative; }
    .grid { grid-template-columns: 1fr; }
}
