:root {
    --bg: #0f172a;
    --panel: #111827;
    --card: #1f2937;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --blue: #2563eb;
    --green: #16a34a;
    --red: #dc2626;
    --border: #374151;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
.sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 235px; background: #020617; border-right: 1px solid var(--border); padding: 24px 18px; }
.brand { font-size: 24px; font-weight: 800; margin-bottom: 30px; line-height: 1.15; }
.brand span { font-size: 13px; color: var(--muted); font-weight: 400; }
nav a { display: block; padding: 13px 14px; border-radius: 12px; margin-bottom: 9px; background: transparent; color: var(--text); }
nav a:hover { background: var(--card); }
nav .logout { color: #fecaca; margin-top: 25px; }
.main { margin-left: 235px; padding: 28px; min-height: 100vh; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
h1 { margin: 0; font-size: 32px; }
h2 { margin-top: 28px; }
.btn, button { background: var(--blue); color: white; border: 0; border-radius: 10px; padding: 10px 15px; cursor: pointer; font-weight: 700; }
button:hover, .btn:hover { filter: brightness(1.1); }
.cards { display: grid; grid-template-columns: repeat(4, minmax(180px, 1fr)); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 18px; box-shadow: 0 10px 20px rgba(0,0,0,.18); }
.card-title { color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.card-value { font-size: 24px; font-weight: 800; }
.table-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; overflow: auto; }
.table-wrap.wide { max-width: 100%; }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th, td { padding: 12px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 14px; }
th { color: #cbd5e1; background: #0b1220; }
tr:hover td { background: rgba(255,255,255,.03); }
.badge { display: inline-block; padding: 5px 9px; border-radius: 999px; background: #334155; font-size: 12px; }
.actions { min-width: 270px; }
.actions a { display: inline-block; background: #334155; padding: 7px 9px; border-radius: 8px; margin: 3px; font-size: 12px; }
.actions form { display: flex; gap: 5px; margin-top: 6px; }
.actions select { max-width: 130px; }
input, select { background: #0b1220; color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 10px; outline: none; }
input:focus, select:focus { border-color: var(--blue); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(240px, 1fr)); gap: 14px; background: var(--panel); padding: 22px; border-radius: 16px; border: 1px solid var(--border); }
.form-grid label { display: flex; flex-direction: column; gap: 7px; color: var(--muted); }
.form-grid .full { grid-column: 1 / -1; }
.inline-form { display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); gap: 10px; background: var(--panel); padding: 16px; border-radius: 16px; border: 1px solid var(--border); margin-bottom: 18px; }
.filters { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 15px; }
.filters a { background: var(--card); padding: 8px 11px; border-radius: 9px; color: #dbeafe; }
.flash-wrap { margin-bottom: 14px; }
.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 8px; }
.flash.success { background: rgba(22,163,74,.18); color: #bbf7d0; border: 1px solid rgba(22,163,74,.4); }
.flash.danger { background: rgba(220,38,38,.18); color: #fecaca; border: 1px solid rgba(220,38,38,.4); }
.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-card { width: 390px; background: var(--panel); border: 1px solid var(--border); border-radius: 22px; padding: 30px; box-shadow: 0 18px 50px rgba(0,0,0,.35); }
.login-card h1 { text-align: center; font-size: 28px; }
.login-card p { text-align: center; color: var(--muted); margin-bottom: 25px; }
.login-card label { display: block; color: var(--muted); margin: 12px 0 6px; }
.login-card input, .login-card button { width: 100%; }
.login-card button { margin-top: 18px; }
@media (max-width: 1050px) {
    .cards { grid-template-columns: repeat(2, 1fr); }
    .inline-form { grid-template-columns: repeat(2, 1fr); }
}


/* Orders table UI fix */
.table-wrap.wide {
    overflow-x: auto;
}

.table-wrap.wide table {
    min-width: 1650px;
}

.table-wrap.wide th,
.table-wrap.wide td {
    vertical-align: middle;
}

.product-cell {
    width: 230px;
    max-width: 230px;
    white-space: normal;
    line-height: 1.25;
}

.actions {
    min-width: 260px;
    white-space: normal;
}

.actions a {
    margin-bottom: 6px;
}

.actions form {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: nowrap;
}

.actions select {
    width: 130px;
}

.actions button {
    padding: 9px 12px;
}

.badge {
    min-width: 82px;
    text-align: center;
}


/* Quick purchase action UI */
.quick-actions {
    min-width: 360px;
}

.quick-actions .action-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 7px;
}

.quick-actions .purchase-form {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 7px;
}

.quick-actions .cost-input {
    width: 95px;
    padding: 8px;
}

.quick-actions button {
    padding: 8px 10px;
    white-space: nowrap;
}

.quick-actions a {
    font-size: 12px;
    padding: 8px 9px;
    white-space: nowrap;
}


/* Profit/Loss display */
.profit-positive {
    color: #bbf7d0;
    background: rgba(22, 163, 74, 0.18);
    border: 1px solid rgba(22, 163, 74, 0.35);
    padding: 7px 10px;
    border-radius: 999px;
    font-weight: 700;
    display: inline-block;
    min-width: 88px;
    text-align: center;
}

.profit-negative {
    color: #fecaca;
    background: rgba(220, 38, 38, 0.18);
    border: 1px solid rgba(220, 38, 38, 0.35);
    padding: 7px 10px;
    border-radius: 999px;
    font-weight: 700;
    display: inline-block;
    min-width: 88px;
    text-align: center;
}


/* COD collection additions */
.quick-actions {
    min-width: 390px;
}


/* Tracking quick form */
.tracking-form {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 7px;
}

.tracking-form input {
    padding: 8px;
}

.courier-input {
    width: 95px;
}

.tracking-input {
    width: 135px;
}

.tracking-form button {
    padding: 8px 10px;
    white-space: nowrap;
}
