/* Admin / utility CSS — dark mode. Functional, not pretty. */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #e8e8f0;
    background: #0f1115;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: #d4a017; text-decoration: none; }
a:hover { color: #f5c842; text-decoration: underline; }

code {
    background: #14171f;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 12px;
    color: #d4a017;
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

/* ---------- Layout ---------- */

.admin-shell { min-height: 100vh; display: flex; flex-direction: column; }

.admin-header {
    background: #14171f;
    color: #e8e8f0;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #2a2d35;
}
.admin-header h1 { font-size: 16px; margin: 0; font-weight: 600; }
.admin-header h1 a { color: #e8e8f0 !important; }
.admin-header h1 a:hover { color: #f5c842 !important; text-decoration: none; }
.admin-header nav a {
    color: #b0b0c0;
    margin-left: 20px;
    font-size: 13px;
}
.admin-header nav a:hover { color: #f5c842; text-decoration: none; }
.admin-header form { display: inline; }
.admin-header .logout-btn {
    background: none;
    border: none;
    color: #b0b0c0;
    font-size: 13px;
    cursor: pointer;
    margin-left: 20px;
    padding: 0;
    font-family: inherit;
}
.admin-header .logout-btn:hover { color: #f5c842; text-decoration: underline; }

.admin-main { flex: 1; padding: 24px; max-width: 1200px; margin: 0 auto; width: 100%; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.page-header h2 { margin: 0; font-size: 22px; font-weight: 600; color: #e8e8f0; }

/* ---------- Auth screen ---------- */

.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0a0c10;
    padding: 20px;
}
.auth-card {
    background: #14171f;
    border: 1px solid #2a2d35;
    padding: 40px;
    border-radius: 8px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.auth-title  { margin: 0 0 4px; font-size: 20px; color: #e8e8f0; }
.auth-subtitle { margin: 0 0 28px; color: #8a8aa0; font-size: 13px; }
.auth-form .form-label { display: block; margin-bottom: 16px; }

/* ---------- Forms ---------- */

.form-label {
    display: block;
    margin-bottom: 14px;
}
.form-label > span {
    display: block;
    margin-bottom: 6px;
    font-size: 11px;
    font-weight: 600;
    color: #d4a017;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.form-label input,
.form-label textarea,
.form-label select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
textarea, select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #2a2d35;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    background: #0f1115;
    color: #e8e8f0;
}
.form-label input:focus,
.form-label textarea:focus,
.form-label select:focus,
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #d4a017;
    box-shadow: 0 0 0 3px rgba(212, 160, 23, 0.18);
}
input::placeholder, textarea::placeholder { color: #5a5d68; }

input[type="checkbox"] {
    width: auto;
    accent-color: #d4a017;
}

textarea { min-height: 80px; resize: vertical; }

.form-row { display: flex; gap: 16px; }
.form-row > * { flex: 1; }

/* ---------- Buttons ---------- */

.btn {
    display: inline-block;
    padding: 8px 16px;
    border: 1px solid #2a2d35;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.4;
    background: #1a1d24;
    color: #e8e8f0;
    font-family: inherit;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: #232732; border-color: #3a3d45; text-decoration: none; color: #e8e8f0; }

.btn-primary { background: #d4a017; color: #0a0c10; border-color: #d4a017; }
.btn-primary:hover { background: #f5c842; border-color: #f5c842; color: #0a0c10; }

.btn-danger  { background: #b03a3a; color: #fff; border-color: #b03a3a; }
.btn-danger:hover { background: #d04848; border-color: #d04848; color: #fff; }

.btn-success { background: #2d8056; color: #fff; border-color: #2d8056; }
.btn-success:hover { background: #36996b; border-color: #36996b; color: #fff; }

.btn-block { display: block; width: 100%; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ---------- Alerts & flash ---------- */

.alert {
    padding: 10px 14px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 13px;
    border: 1px solid;
}
.alert-error   { background: rgba(180,80,80,0.12);  color: #ec8888; border-color: rgba(180,80,80,0.35); }
.alert-success { background: rgba(64,200,128,0.10); color: #6fdba0; border-color: rgba(64,200,128,0.30); }
.alert-info    { background: rgba(64,128,255,0.10); color: #80a8ff; border-color: rgba(64,128,255,0.30); }

/* ---------- Tables ---------- */

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #14171f;
    border: 1px solid #2a2d35;
    border-radius: 4px;
    overflow: hidden;
}
.data-table th, .data-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid #2a2d35;
    font-size: 13px;
    color: #e8e8f0;
}
.data-table th {
    background: #1a1d24;
    font-weight: 600;
    color: #d4a017;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.data-table tr:hover td { background: #1a1d24; }
.data-table tr:last-child td { border-bottom: none; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; font-family: ui-monospace, Consolas, monospace; }

.data-table a { color: #d4a017; }
.data-table a:hover { color: #f5c842; }

/* ---------- Status badges ---------- */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: 1px solid;
}
.badge-draft   { background: rgba(138,138,160,0.12); color: #b0b0c0; border-color: rgba(138,138,160,0.30); }
.badge-sent    { background: rgba(64,128,255,0.12); color: #80a8ff; border-color: rgba(64,128,255,0.30); }
.badge-viewed  { background: rgba(212,160,23,0.12); color: #d4a017; border-color: rgba(212,160,23,0.30); }
.badge-paid    { background: rgba(64,200,128,0.12); color: #6fdba0; border-color: rgba(64,200,128,0.30); }
.badge-void    { background: rgba(180,80,80,0.12);  color: #d07070; border-color: rgba(180,80,80,0.25); text-decoration: line-through; }
.badge-expired { background: rgba(180,80,80,0.12);  color: #d07070; border-color: rgba(180,80,80,0.25); }

/* ---------- Card / panel ---------- */

.card {
    background: #14171f;
    border: 1px solid #2a2d35;
    padding: 20px;
    border-radius: 6px;
    margin-bottom: 16px;
}
.card h3 {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 600;
    color: #d4a017;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ---------- Filters bar ---------- */

.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    background: #14171f;
    border: 1px solid #2a2d35;
    padding: 12px;
    border-radius: 6px;
}
.filter-bar select,
.filter-bar input {
    padding: 6px 10px;
    border: 1px solid #2a2d35;
    border-radius: 4px;
    font-size: 13px;
    background: #0f1115;
    color: #e8e8f0;
    width: auto;
}

/* ---------- Action group ---------- */

.action-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Line item builder ---------- */

.line-items {
    margin-bottom: 16px;
}
.line-item-row {
    display: grid;
    grid-template-columns: 1fr 80px 120px 120px 32px;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}
.line-item-row input { padding: 6px 8px; font-size: 13px; }
.line-item-row .remove-btn {
    background: rgba(180,80,80,0.12);
    color: #ec8888;
    border: 1px solid rgba(180,80,80,0.25);
    border-radius: 4px;
    cursor: pointer;
    height: 32px;
    font-size: 16px;
    line-height: 1;
}
.line-item-row .remove-btn:hover {
    background: rgba(180,80,80,0.20);
    border-color: rgba(180,80,80,0.45);
}
.line-item-totals {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #2a2d35;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: #b0b0c0;
}
.line-item-totals .total-row { padding: 4px 0; }
.line-item-totals .total-row.grand {
    font-size: 18px;
    font-weight: 700;
    color: #e8e8f0;
    padding-top: 8px;
    border-top: 1px solid #2a2d35;
    margin-top: 4px;
}

/* ---------- Empty state ---------- */

.empty-state {
    background: #14171f;
    border: 1px solid #2a2d35;
    padding: 48px 20px;
    text-align: center;
    color: #8a8aa0;
    border-radius: 6px;
}
.empty-state a { color: #d4a017; }

/* ---------- Misc ---------- */

p { margin: 0 0 12px; }
strong { color: #e8e8f0; }
hr { border: 0; border-top: 1px solid #2a2d35; margin: 16px 0; }

::selection { background: rgba(212, 160, 23, 0.4); color: #fff; }

/* ---------- Modal dialog ---------- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.modal-backdrop.open { opacity: 1; }

.modal-card {
    position: relative;
    background: #14171f;
    border: 1px solid #2a2d35;
    border-radius: 8px;
    padding: 24px 24px 20px;
    max-width: 440px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    transform: translateY(8px);
    transition: transform 0.15s ease;
}

.modal-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #8a8aa0;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    border-radius: 4px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}
.modal-close:hover { background: #232732; color: #e8e8f0; }
.modal-close:focus-visible { outline: 2px solid #d4a017; outline-offset: 1px; }
.modal-backdrop.open .modal-card { transform: translateY(0); }

.modal-message {
    margin: 0 0 20px;
    font-size: 15px;
    color: #e8e8f0;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Scrollbar (Webkit only — Chrome/Edge) */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: #0f1115; }
::-webkit-scrollbar-thumb { background: #2a2d35; border-radius: 6px; border: 3px solid #0f1115; }
::-webkit-scrollbar-thumb:hover { background: #3a3d45; }
