:root {
    --bg: #f6f7f9;
    --card: #ffffff;
    --border: #e5e7eb;
    --text: #111827;
    --muted: #6b7280;
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --success: #16a34a;
    --error: #dc2626;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 220px;
    background: #111827;
    color: #e5e7eb;
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    flex-shrink: 0;
}
.sidebar .brand { font-size: 20px; font-weight: 700; color: #fff; padding: 0 24px 20px; }
.sidebar nav { display: flex; flex-direction: column; flex: 1; }
.sidebar nav a {
    padding: 11px 24px;
    color: #9ca3af;
    font-weight: 500;
}
.sidebar nav a:hover { color: #fff; text-decoration: none; background: rgba(255,255,255,0.05); }
.sidebar nav a.active { color: #fff; background: var(--primary); }
.sidebar-footer { padding: 16px 24px; border-top: 1px solid rgba(255,255,255,0.1); font-size: 13px; }
.sidebar-footer .user { color: #fff; margin-bottom: 4px; }
.sidebar-footer a { color: #9ca3af; }

.content { flex: 1; padding: 32px 40px; max-width: 1100px; }

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 16px; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.subtitle { color: var(--muted); margin: 0 0 20px; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 20px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.stat .value { font-size: 24px; font-weight: 700; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 9px 16px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f3f4f6; }
.btn-danger { background: #fff; color: var(--error); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Tables */
table.list { width: 100%; border-collapse: collapse; }
table.list th {
    text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border);
}
table.list td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.list tr:last-child td { border-bottom: none; }
table.list tr:hover { background: #fafafa; }
.actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 12px; color: #fff; font-size: 11px; font-weight: 600; text-transform: uppercase; }

/* Forms */
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; margin-top: 16px; }
label:first-child { margin-top: 0; }
input[type=text], input[type=email], input[type=number], input[type=password],
input[type=date], input[type=tel], select, textarea {
    width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 6px;
    font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
}
textarea { resize: vertical; min-height: 70px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-actions { margin-top: 24px; display: flex; gap: 10px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* Line items editor */
.line-items table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.line-items th { text-align: left; font-size: 11px; text-transform: uppercase; color: var(--muted); padding: 6px; }
.line-items td { padding: 6px; }
.line-items input { width: 100%; }
.line-items .col-qty, .line-items .col-price, .line-items .col-total { width: 110px; }
.line-items .col-remove { width: 36px; }
.totals-box { margin-top: 16px; margin-left: auto; width: 280px; }
.totals-box .row { display: flex; justify-content: space-between; padding: 6px 0; }
.totals-box .row.grand { border-top: 2px solid var(--text); font-weight: 700; font-size: 16px; padding-top: 10px; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; font-size: 13px; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* Login page */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 40px; width: 360px; }
.login-card h1 { text-align: center; margin-bottom: 24px; }

.empty-state { text-align: center; color: var(--muted); padding: 60px 20px; }

.text-muted { color: var(--muted); }
.text-right { text-align: right; }
