:root {
    --font-sans: "DM Sans", "Segoe UI", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", "Consolas", monospace;

    --navy: #0f2d52;
    --navy-dark: #0a2240;
    --navy-muted: #5a7190;
    --green: #15803d;
    --green-light: #dcfce7;
    --green-dark: #14532d;
    --white: #ffffff;
    --off-white: #f4f7fb;

    --color-bg: var(--off-white);
    --color-surface: var(--white);
    --color-border: #d4dce8;
    --color-text: var(--navy-dark);
    --color-muted: var(--navy-muted);
    --color-primary: var(--navy);
    --color-accent: var(--green);

    --radius-sm: 4px;
    --radius-md: 6px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    font-size: 13px;
    line-height: 1.4;
}

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

a:hover {
    text-decoration: underline;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px;
}

.container-wide {
    max-width: 1520px;
}

/* ── Topbar ── */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--navy-dark);
    color: var(--white);
    border-bottom: 2px solid var(--green);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--green);
    color: var(--white);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    display: grid;
    place-items: center;
}

.topbar h1 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.topbar-sub,
.topbar .muted {
    margin: 1px 0 0;
    color: rgba(255, 255, 255, 0.65);
    font-size: 11px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-chip {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
}

/* ── Card ── */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: 12px;
    border: 1px solid var(--color-border);
}

.dashboard-card {
    padding: 10px 12px 12px;
}

.card h1,
.card h2 {
    margin: 0;
    font-weight: 600;
    font-size: 1rem;
    color: var(--navy);
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.section-meta {
    margin: 2px 0 0;
    font-size: 11px;
    color: var(--color-muted);
    display: flex;
    align-items: center;
    gap: 5px;
}

.live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
}

.stat-chip strong {
    color: var(--navy);
    font-weight: 600;
}

.stat-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--color-muted);
}

.stat-chip {
    padding: 0;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-muted);
}

.stat-chip-total::after {
    content: " ·";
    margin-left: 4px;
    color: var(--color-border);
}

/* ── Filters ── */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding: 0;
}

.filter-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--navy);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.filter-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: var(--white);
    color: var(--navy);
    font-size: 12px;
    font-weight: 500;
}

.filter-pill:hover {
    border-color: var(--navy);
    text-decoration: none;
}

.filter-pill.is-active,
.filter-pill-evc_gstr1.is-active,
.filter-pill-evc_gstr3b.is-active,
.filter-pill-new_application.is-active,
.filter-pill-password_reset.is-active,
.filter-pill-other.is-active {
    background: var(--navy);
    border-color: var(--navy);
    color: var(--white);
}

/* ── Table ── */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.otp-table {
    table-layout: fixed;
    min-width: 1320px;
}

.otp-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--navy);
    border-bottom: 1px solid var(--navy-dark);
}

th {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--white);
    font-weight: 600;
    white-space: nowrap;
}

.otp-table tbody tr:nth-child(even) {
    background: var(--off-white);
}

.otp-table tbody tr:hover {
    background: #e8eef6;
}

.col-received { width: 100px; }
.col-otp      { width: 210px; }
.col-expires  { width: 100px; }
.col-type     { width: 120px; }
.col-name     { width: 130px; }
.col-gstin    { width: 170px; }
.col-subject  { width: 15%; min-width: 140px; }
.col-details  { width: auto; min-width: 160px; }

.col-received,
.col-expires {
    white-space: nowrap;
}

.col-subject,
.col-details {
    vertical-align: top;
}

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

.date-primary {
    display: block;
    font-weight: 500;
    color: var(--navy-dark);
    font-size: 12px;
    white-space: nowrap;
}

.date-secondary {
    display: block;
    font-size: 11px;
    color: var(--color-muted);
    margin-top: 1px;
    white-space: nowrap;
}

/* ── OTP & copy ── */
.otp-badge {
    display: inline-block;
    flex-shrink: 0;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    background: var(--green-light);
    color: var(--green-dark);
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.08em;
    white-space: nowrap;
    border: 1px solid var(--green);
    min-width: 72px;
    text-align: center;
}

.otp-copy-wrap {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.btn-copy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--navy);
    cursor: pointer;
}

.btn-copy svg {
    display: block;
    flex-shrink: 0;
}

.btn-copy .icon-check {
    display: none;
}

.btn-copy.is-copied .icon-copy {
    display: none;
}

.btn-copy.is-copied .icon-check {
    display: block;
}

.btn-copy:hover {
    border-color: var(--green);
    color: var(--green);
    background: var(--green-light);
}

.btn-copy.is-copied {
    border-color: var(--green);
    color: var(--green);
    background: var(--green-light);
}

.copy-feedback {
    display: inline-block;
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    color: var(--green);
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.15s ease, max-width 0.2s ease;
}

.otp-copy-wrap.is-copied .copy-feedback {
    opacity: 1;
    max-width: 60px;
}

/* ── Cell content ── */
.gstin-badge {
    display: inline-block;
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 11px;
    letter-spacing: 0.04em;
    white-space: nowrap;
    color: var(--navy);
}

.gstin-empty {
    color: var(--color-muted);
    font-size: 12px;
}

.name-badge {
    display: inline-block;
    max-width: 100%;
    font-weight: 500;
    font-size: 12px;
    line-height: 1.3;
    color: var(--navy-dark);
    word-break: break-word;
}

.name-badge-user {
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: lowercase;
}

.type-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    color: var(--navy-muted);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.expires-badge {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
}

.expires-badge-active .date-primary,
.expires-badge-active .date-secondary {
    color: var(--navy-dark);
}

.expires-badge-lapsed .date-primary,
.expires-badge-lapsed .date-secondary {
    color: var(--navy-muted);
    text-decoration: line-through;
}

.cell-clamp {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    word-break: break-word;
    line-height: 1.35;
    color: var(--navy);
    font-size: 12px;
}

.excerpt-details {
    margin: 0;
}

.excerpt-details summary {
    cursor: pointer;
    color: var(--navy);
    font-size: 12px;
    line-height: 1.35;
    word-break: break-word;
    list-style: none;
}

.excerpt-details summary::-webkit-details-marker {
    display: none;
}

.excerpt-details summary::before {
    content: "▸ ";
    color: var(--navy-muted);
}

.excerpt-details[open] summary::before {
    content: "▾ ";
}

.excerpt-full {
    margin: 4px 0 0;
    padding: 6px 8px;
    background: var(--off-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 11px;
    line-height: 1.4;
    word-break: break-word;
    max-height: 100px;
    overflow-y: auto;
    color: var(--navy-dark);
}

/* ── Pagination ── */
.pagination-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--color-border);
}

.pagination-info {
    font-size: 12px;
    color: var(--color-muted);
}

.pagination-info strong {
    color: var(--navy);
    font-weight: 600;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.page-indicator {
    padding: 3px 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--navy);
    white-space: nowrap;
}

.per-page {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.per-page-label {
    font-size: 12px;
    color: var(--color-muted);
}

.per-page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    padding: 3px 7px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    font-size: 12px;
    font-weight: 500;
    color: var(--navy);
    background: var(--white);
}

.per-page-link:hover,
.per-page-link.is-active {
    background: var(--navy);
    border-color: var(--navy);
    color: var(--white);
    text-decoration: none;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 0;
    font: inherit;
    font-weight: 500;
    font-size: 12px;
    cursor: pointer;
}

.btn-primary {
    background: var(--navy);
    color: var(--white);
}

.btn-primary:hover {
    opacity: 0.92;
}

.btn-secondary {
    background: var(--white);
    color: var(--navy);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: var(--off-white);
    border-color: var(--navy);
}

.btn-ghost {
    background: transparent;
    color: var(--white);
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 12px;
    text-decoration: none;
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.12);
    text-decoration: none;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

.is-disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* ── Auth page ── */
.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 16px;
}

.auth-card {
    width: 100%;
    max-width: 380px;
}

.auth-card h1 {
    color: var(--navy);
}

.stack {
    display: grid;
    gap: 12px;
}

label {
    display: grid;
    gap: 4px;
    font-size: 13px;
    font-weight: 500;
    color: var(--navy-dark);
}

input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: 13px;
}

input:focus {
    outline: none;
    border-color: var(--green);
}

.muted {
    color: var(--color-muted);
    font-size: 12px;
}

.alert {
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    font-size: 12px;
}

.alert-error {
    background: var(--off-white);
    color: var(--navy);
    border: 1px solid var(--color-border);
}

.empty-state {
    margin: 0;
    padding: 20px 12px;
    text-align: center;
    color: var(--color-muted);
    font-size: 12px;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-sm);
}

.nowrap {
    white-space: nowrap;
}

@media (max-width: 768px) {
    .topbar,
    .section-head,
    .pagination-bar {
        flex-direction: column;
        align-items: flex-start;
    }
}
