/* Spectio Billing — Wave-inspired UI */

:root {
    --c-bg:        #f7f8fa;
    --c-card:      #ffffff;
    --c-border:    #e5e7eb;
    --c-border-2:  #d1d5db;
    --c-text:      #111827;
    --c-muted:     #6b7280;
    --c-muted-2:   #9ca3af;
    --c-primary:   #2563eb;
    --c-primary-d: #1d4ed8;
    --c-accent:    #0e7490;
    --c-success:   #10b981;
    --c-warn:      #f59e0b;
    --c-danger:    #ef4444;
    --radius:      8px;
    --shadow:      0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

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

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

/* Layout */
.app {
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: #1e293b;
    color: #e2e8f0;
    padding: 20px 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar .brand {
    padding: 0 20px 20px;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
    border-bottom: 1px solid #334155;
    margin-bottom: 12px;
}
.sidebar .brand small { display: block; font-weight: 400; color: #94a3b8; font-size: 12px; }
.sidebar nav { display: flex; flex-direction: column; }
.sidebar nav a {
    color: #cbd5e1;
    padding: 10px 20px;
    font-size: 14px;
    border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: #334155; text-decoration: none; color: #fff; }
.sidebar nav a.active { background: #0f172a; border-left-color: var(--c-primary); color: #fff; }
.sidebar .section-label {
    padding: 14px 20px 6px; font-size: 11px;
    text-transform: uppercase; letter-spacing: 0.08em;
    color: #64748b;
}

.main { padding: 24px 32px 60px; max-width: 1200px; }

/* Page header */
.page-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; gap: 12px;
}
.page-head h1 {
    font-size: 22px; font-weight: 600; margin: 0;
    letter-spacing: -0.01em;
}
.page-head .actions { display: flex; gap: 8px; }

/* Cards */
.card {
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.card-pad { padding: 20px; }
.card-head {
    padding: 14px 20px;
    border-bottom: 1px solid var(--c-border);
    font-weight: 600;
}

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: #fff; color: var(--c-text);
    border: 1px solid var(--c-border-2);
    padding: 8px 14px; border-radius: 6px;
    font-size: 14px; font-weight: 500; cursor: pointer;
    transition: all 0.12s ease;
}
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn.primary { background: var(--c-primary); color: white; border-color: var(--c-primary); }
.btn.primary:hover { background: var(--c-primary-d); border-color: var(--c-primary-d); color: white; }
.btn.success { background: var(--c-success); color: white; border-color: var(--c-success); }
.btn.success:hover { background: #059669; border-color: #059669; color: white; }
.btn.danger { background: #fff; color: var(--c-danger); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--c-muted); }
.btn.ghost:hover { background: #f3f4f6; color: var(--c-text); }
.btn.sm { padding: 4px 10px; font-size: 12px; }

/* Forms */
label { display: block; font-size: 12px; font-weight: 500; color: var(--c-muted); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=number], input[type=date],
input[type=tel], input[type=url], input[type=password], select, textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--c-border-2);
    border-radius: 6px;
    font: inherit;
    background: #fff;
    color: var(--c-text);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
textarea { min-height: 70px; resize: vertical; }
.field { margin-bottom: 14px; }
.field-grid { display: grid; gap: 12px; }
.field-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.field-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.field-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* Tables */
table.data { width: 100%; border-collapse: collapse; }
table.data th {
    text-align: left; font-weight: 500; font-size: 12px;
    text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--c-muted);
    padding: 10px 14px; border-bottom: 1px solid var(--c-border);
    background: #f9fafb;
}
table.data td {
    padding: 12px 14px; border-bottom: 1px solid #f1f3f5;
    vertical-align: middle;
}
table.data tr:hover td { background: #fafbfc; }
table.data tr:last-child td { border-bottom: 0; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }

/* Pills / status */
.pill {
    display: inline-block; padding: 2px 10px; border-radius: 999px;
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.04em;
    background: #f3f4f6; color: var(--c-muted);
}
.pill.draft    { background: #f3f4f6;  color: #4b5563; }
.pill.sent     { background: #dbeafe;  color: #1e40af; }
.pill.paid     { background: #d1fae5;  color: #065f46; }
.pill.accepted { background: #d1fae5;  color: #065f46; }
.pill.declined { background: #fee2e2;  color: #991b1b; }
.pill.void     { background: #fee2e2;  color: #991b1b; }
.pill.overdue  { background: #fee2e2;  color: #991b1b; }

.cat-chip {
    display: inline-block; padding: 2px 8px; border-radius: 4px;
    font-size: 11px; font-weight: 500; color: white;
}

/* Stats */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat-card {
    background: white;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 16px;
}
.stat-label { font-size: 12px; color: var(--c-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 22px; font-weight: 600; margin-top: 4px; letter-spacing: -0.01em; }
.stat-value.paid     { color: var(--c-success); }
.stat-value.outstanding { color: var(--c-warn); }
.stat-value.draft    { color: var(--c-muted); }

/* Flash messages */
.flash-stack { position: fixed; top: 16px; right: 16px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.flash {
    padding: 10px 14px; border-radius: 6px; min-width: 240px;
    background: white; box-shadow: 0 4px 14px rgba(0,0,0,0.1);
    font-size: 13px;
    border-left: 4px solid var(--c-primary);
}
.flash.success { border-left-color: var(--c-success); }
.flash.error   { border-left-color: var(--c-danger); }

/* Invoice form */
.invoice-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.invoice-meta .from-block, .invoice-meta .to-block { padding: 6px 0; }
.invoice-meta h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--c-muted); margin: 0 0 6px; }

.line-table { width: 100%; border-collapse: collapse; }
.line-table th {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--c-muted); font-weight: 500; padding: 8px;
    border-bottom: 2px solid var(--c-border);
    text-align: left;
}
.line-table th.numeric { text-align: right; }
.line-table td { padding: 6px 4px; vertical-align: top; border-bottom: 1px solid #f1f3f5; }
.line-table tr.line-row td { padding-top: 8px; padding-bottom: 8px; }
.line-table input, .line-table select, .line-table textarea {
    border: 1px solid transparent;
    background: transparent;
    padding: 6px 8px;
}
.line-table input:hover, .line-table select:hover, .line-table textarea:hover {
    border-color: var(--c-border);
    background: #fafafa;
}
.line-table input:focus, .line-table select:focus, .line-table textarea:focus {
    background: #fff;
    border-color: var(--c-primary);
}
.line-table .col-amount { text-align: right; font-variant-numeric: tabular-nums; padding-right: 10px; font-weight: 500; }
.line-table .col-remove { width: 32px; }

.totals-block {
    display: grid; grid-template-columns: 1fr 320px; gap: 24px; margin-top: 16px;
}
.totals-table { width: 100%; }
.totals-table tr td { padding: 6px 0; border: none; }
.totals-table tr td:first-child { color: var(--c-muted); }
.totals-table tr td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.totals-table tr.grand-total td { padding-top: 12px; border-top: 2px solid var(--c-border); font-size: 18px; font-weight: 600; color: var(--c-text); }

/* Invoice view */
.invoice-view {
    background: white; padding: 56px 64px; border-radius: var(--radius);
    box-shadow: var(--shadow); border: 1px solid var(--c-border);
}
.invoice-view header { display: flex; justify-content: space-between; margin-bottom: 40px; }
.invoice-view h1 { margin: 0 0 4px; font-size: 32px; letter-spacing: -0.02em; color: var(--c-text); font-weight: 700; }
.invoice-view .doc-meta { text-align: right; color: var(--c-muted); font-size: 13px; }
.invoice-view .doc-meta .num { color: var(--c-text); font-weight: 600; font-size: 16px; margin-bottom: 4px; }
.invoice-view .parties { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; margin-bottom: 32px; }
.invoice-view .parties h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--c-muted); margin: 0 0 6px; font-weight: 600; }
.invoice-view .parties .name { font-weight: 600; }
.invoice-view .totals-block { margin-top: 24px; }

@media print {
    .sidebar, .page-head, .flash-stack, .no-print { display: none !important; }
    .app { display: block; }
    .main { padding: 0; max-width: none; }
    .invoice-view { box-shadow: none; border: 0; padding: 0; }
}

/* Empty state */
.empty {
    text-align: center; padding: 60px 20px; color: var(--c-muted);
    border: 2px dashed var(--c-border-2);
    border-radius: var(--radius);
    background: white;
}
.empty h3 { color: var(--c-text); margin: 0 0 8px; font-weight: 600; }

/* Misc */
.row { display: flex; gap: 8px; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.muted { color: var(--c-muted); }
.right { text-align: right; }
.small { font-size: 12px; }
.mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-12 { margin-bottom: 12px; }
hr.soft { border: 0; border-top: 1px solid var(--c-border); margin: 16px 0; }
