:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --text: #17202a;
    --muted: #697386;
    --border: #dfe3e8;
    --primary: #1f2937;
    --danger: #b42318;
    --success: #067647;
    --warning: #b54708;
    --radius: 12px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

a { color: inherit; }

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

.sidebar {
    width: 250px;
    background: #111827;
    color: #fff;
    padding: 24px 18px;
    position: fixed;
    inset: 0 auto 0 0;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 34px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    background: #fff;
    color: #111827;
    border-radius: 10px;
    font-weight: 800;
}

.brand small {
    display: block;
    opacity: .65;
    margin-top: 3px;
}

.sidebar nav {
    display: grid;
    gap: 6px;
}

.sidebar nav a {
    text-decoration: none;
    padding: 12px 14px;
    border-radius: 8px;
    color: #e5e7eb;
}

.sidebar nav a:hover {
    background: rgba(255,255,255,.08);
}

.main-content {
    margin-left: 250px;
    width: calc(100% - 250px);
    padding: 30px;
}

.auth-content {
    width: 100%;
    display: grid;
    place-items: center;
    padding: 24px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.topbar h1 { margin: 0 0 6px; }
.topbar p { margin: 0; color: var(--muted); }

.admin-name {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 9px 14px;
}

.grid {
    display: grid;
    gap: 18px;
}

.grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
}

.stat {
    font-size: 34px;
    font-weight: 800;
    margin: 8px 0;
}

.muted { color: var(--muted); }

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    text-align: left;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

th {
    font-size: 13px;
    color: var(--muted);
    background: #fafafa;
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 8px;
    padding: 10px 14px;
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    font-weight: 700;
}

.btn-secondary {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-danger { background: var(--danger); }

.form-card {
    max-width: 760px;
}

.form-card-wide { max-width: 1120px; }

.invoice-section {
    border-top: 1px solid var(--border);
    padding-top: 22px;
}

.invoice-section:first-of-type { border-top: 0; padding-top: 0; }

.invoice-section h2 { margin: 0 0 6px; font-size: 18px; }
.invoice-section > p { margin: 0 0 18px; }

.line-items { display: grid; gap: 10px; }

.line-item {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 100px 140px 44px;
    gap: 10px;
    align-items: end;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fafafa;
}

.line-item.recurring { grid-template-columns: minmax(220px, 1fr) 100px 140px 150px 44px; }
.line-item label { font-size: 13px; }
.icon-btn { height: 44px; padding: 0; font-size: 20px; }

.invoice-summary {
    margin-left: auto;
    width: min(390px, 100%);
    display: grid;
    gap: 10px;
}

.invoice-summary div { display: flex; justify-content: space-between; gap: 20px; }
.invoice-summary .grand-total { border-top: 2px solid var(--text); padding-top: 12px; font-size: 20px; font-weight: 800; }

.help-text { color: var(--muted); font-size: 13px; font-weight: 400; }
.required-mark { color: var(--danger); }

.form-grid {
    display: grid;
    gap: 18px;
}

.form-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
    display: grid;
    gap: 7px;
    font-weight: 700;
}

input, select, textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    background: #fff;
    font: inherit;
}

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

.alert {
    padding: 14px 16px;
    border-radius: 9px;
    margin-bottom: 18px;
}

.alert-success { background: #ecfdf3; color: var(--success); }
.alert-error { background: #fef3f2; color: var(--danger); }
.alert-warning { background: #fffaeb; color: var(--warning); }

.badge {
    display: inline-flex;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.badge-active { background: #ecfdf3; color: var(--success); }
.badge-suspended { background: #fef3f2; color: var(--danger); }
.badge-expired { background: #fffaeb; color: var(--warning); }
.badge-trial { background: #eef4ff; color: #3538cd; }
.badge-draft { background: #f2f4f7; color: #344054; }
.badge-sent { background: #eef4ff; color: #3538cd; }
.badge-paid { background: #ecfdf3; color: var(--success); }
.badge-overdue, .badge-cancelled { background: #fef3f2; color: var(--danger); }

.auth-card {
    width: min(440px, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 30px;
}

.auth-card h1 { margin-top: 0; }

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin: 26px 0 14px;
}

code.license {
    white-space: nowrap;
    font-size: 13px;
}

@media (max-width: 900px) {
    .sidebar {
        position: static;
        width: 100%;
    }

    .app-shell {
        display: block;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .grid-4,
    .form-grid.two {
        grid-template-columns: 1fr;
    }

    .line-item,
    .line-item.recurring { grid-template-columns: 1fr 1fr; }

    .line-item .description-field { grid-column: 1 / -1; }
}
