/* CyberCash Management — dashboard styles */

:root {
    --brand-1: #667eea;
    --brand-2: #764ba2;
    --ink: #1f2430;
    --ink-soft: #5c6472;
    --muted: #8b93a1;
    --line: #e3e7ee;
    --surface: #ffffff;
    --surface-alt: #f6f7fb;
    --bg: #eef1f7;
    --ok: #1a8f4c;
    --ok-soft: #e3f6ea;
    --warn: #a16207;
    --warn-soft: #fdf4dc;
    --err: #b42318;
    --err-soft: #fde8e6;
    --radius: 12px;
    --shadow: 0 12px 30px rgba(23, 32, 56, 0.09);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
    min-height: 100vh;
}

.is-hidden {
    display: none !important;
}

/* ---------- Header ---------- */

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1.25rem 1.75rem;
    background: linear-gradient(120deg, var(--brand-1) 0%, var(--brand-2) 100%);
    color: #fff;
    box-shadow: 0 6px 18px rgba(76, 61, 140, 0.28);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.35);
    font-weight: 700;
    letter-spacing: 0.05em;
}

.brand-text h1 {
    font-size: 1.35rem;
    font-weight: 650;
    letter-spacing: 0.01em;
}

.brand-text p {
    font-size: 0.85rem;
    opacity: 0.82;
}

.conn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-size: 0.82rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.user-chip {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    padding: 0.3rem 0.8rem;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.user-chip .user-name {
    font-size: 0.82rem;
    font-weight: 700;
}

.user-chip .user-email {
    font-size: 0.72rem;
    opacity: 0.85;
}

.app-header .btn-ghost {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.4);
}

.app-header .btn-ghost:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.14);
}

.app-header .btn-secondary {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.34);
    color: #fff;
}

.app-header .btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.24);
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

.conn-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #ffd166;
    box-shadow: 0 0 0 3px rgba(255, 209, 102, 0.25);
}

.conn[data-state="ok"] .conn-dot {
    background: #6ee7a0;
    box-shadow: 0 0 0 3px rgba(110, 231, 160, 0.28);
}

.conn[data-state="error"] .conn-dot {
    background: #ffb4ab;
    box-shadow: 0 0 0 3px rgba(255, 180, 171, 0.28);
}

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

.app-main {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 1.75rem 1.25rem 3rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* ---------- Stat cards ---------- */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    box-shadow: 0 2px 10px rgba(23, 32, 56, 0.04);
}

.stat-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 600;
}

.stat-value {
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    margin-top: 0.2rem;
}

/* ---------- Panels ---------- */

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.35rem 1.5rem 1.5rem;
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.panel-title h2 {
    font-size: 1.15rem;
    font-weight: 650;
}

.panel-sub {
    font-size: 0.84rem;
    color: var(--muted);
    margin-top: 0.15rem;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

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

.btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 9px;
    padding: 0.55rem 0.95rem;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(120deg, var(--brand-1), var(--brand-2));
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.28);
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 7px 16px rgba(102, 126, 234, 0.34);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

.btn:focus-visible {
    outline: 3px solid rgba(102, 126, 234, 0.4);
    outline-offset: 2px;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-secondary {
    background: var(--surface-alt);
    color: var(--ink);
    border-color: var(--line);
    box-shadow: none;
}

.btn-secondary:hover:not(:disabled) {
    background: #eceff7;
    box-shadow: none;
}

.btn-ghost {
    background: transparent;
    color: var(--ink-soft);
    border-color: var(--line);
    box-shadow: none;
}

.btn-ghost:hover:not(:disabled) {
    background: var(--surface-alt);
    box-shadow: none;
}

/* ---------- Status line ---------- */

.status {
    border-radius: 9px;
    padding: 0.6rem 0.85rem;
    font-size: 0.86rem;
    font-weight: 600;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.status-loading {
    background: var(--warn-soft);
    color: var(--warn);
    border-color: #f0dcae;
}

.status-success {
    background: var(--ok-soft);
    color: var(--ok);
    border-color: #bfe8cd;
}

.status-error {
    background: var(--err-soft);
    color: var(--err);
    border-color: #f6c9c4;
}

body.is-busy {
    cursor: progress;
}

/* ---------- Table ---------- */

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    min-width: 640px;
}

.data-table thead th {
    text-align: left;
    padding: 0.75rem 1rem;
    background: var(--surface-alt);
    color: var(--ink-soft);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 0.72rem 1rem;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
    color: var(--ink);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: #f8f9fe;
}

.cell-strong {
    font-weight: 650;
}

.cell-mono {
    font-family: 'Cascadia Mono', Consolas, 'Courier New', monospace;
    font-size: 0.84rem;
    color: var(--ink-soft);
}

/* ---------- Badges ---------- */

.badge {
    display: inline-block;
    padding: 0.18rem 0.6rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    border: 1px solid transparent;
    white-space: nowrap;
}

.badge-active {
    background: var(--ok-soft);
    color: var(--ok);
    border-color: #bfe8cd;
}

.badge-inactive {
    background: var(--err-soft);
    color: var(--err);
    border-color: #f6c9c4;
}

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

.empty {
    padding: 2.4rem 1rem;
    text-align: center;
}

.empty-title {
    font-weight: 650;
    margin-bottom: 0.3rem;
}

.muted {
    color: var(--muted);
    font-size: 0.88rem;
}

/* ---------- Raw JSON ---------- */

.raw {
    margin-top: 1rem;
    border-top: 1px dashed var(--line);
    padding-top: 0.85rem;
}

.raw summary {
    cursor: pointer;
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--ink-soft);
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    user-select: none;
}

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

.raw summary::before {
    content: '▸';
    display: inline-block;
    transition: transform 0.15s ease;
    color: var(--brand-1);
}

.raw[open] summary::before {
    transform: rotate(90deg);
}

.raw pre {
    margin-top: 0.75rem;
    padding: 0.9rem 1rem;
    background: #1f2430;
    color: #d7dce8;
    border-radius: 9px;
    overflow-x: auto;
    font-family: 'Cascadia Mono', Consolas, 'Courier New', monospace;
    font-size: 0.78rem;
    line-height: 1.55;
    max-height: 340px;
}

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

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem 1.25rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.field-wide {
    grid-column: 1 / -1;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.25rem;
}

.field label,
.field-label {
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--ink-soft);
}

.field input[type="text"],
.field input[type="email"],
.field input[type="tel"],
.field input[type="number"],
.field select {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
    font-size: 0.9rem;
    color: var(--ink);
    background: #fff;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.field select {
    width: 100%;
    cursor: pointer;
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: var(--brand-1);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.18);
}

.check {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.87rem;
    font-weight: 500;
    color: var(--ink);
    cursor: pointer;
}

.check input {
    accent-color: var(--brand-1);
    width: 16px;
    height: 16px;
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    padding-top: 0.25rem;
}

/* ---------- Responsive ---------- */

@media (max-width: 620px) {
    .app-header {
        padding: 1rem 1.1rem;
    }

    .app-main {
        padding: 1.1rem 0.85rem 2.5rem;
    }

    .panel {
        padding: 1.1rem 1rem 1.25rem;
    }

    .actions {
        width: 100%;
    }

    .actions .btn {
        flex: 1 1 auto;
    }
}
