/* ── Reset & base ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --sidebar-bg:      #243a3a;
    --sidebar-hover:   #2e4e4e;
    --sidebar-active:  #3a6060;
    --sidebar-text:    #a8c4c4;
    --sidebar-label:   #5a8080;
    --sidebar-logo:    #ffffff;
    --sidebar-width:   200px;

    --topbar-bg:       #1a2e2e;
    --topbar-text:     #c8dcdc;
    --topbar-height:   42px;

    --bg:              #ece8df;
    --surface:         #ffffff;
    --border:          #d0cac0;
    --border-light:    #e4e0d8;

    --text:            #1a2828;
    --text-muted:      #5a6e6e;
    --text-light:      #8a9e9e;

    --teal:            #3a7a70;
    --teal-dark:       #2a5a52;
    --teal-light:      #e8f2f0;

    --green:           #2a7a50;
    --green-bg:        #e8f5ee;
    --red:             #b03535;
    --red-bg:          #faeaea;
    --orange:          #c07020;
    --orange-bg:       #fef3e2;

    --table-header:    #4e7a72;
    --table-alt:       #f5f1eb;
    --table-hover:     #eae6de;

    --font-ui:    system-ui, -apple-system, sans-serif;
    --font-mono:  'SF Mono', 'Fira Code', 'Consolas', monospace;
    --font-size:  13px;
}

body {
    font-family: var(--font-ui);
    font-size: var(--font-size);
    color: var(--text);
    background: var(--bg);
    line-height: 1.45;
}

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

/* ── Layout ───────────────────────────────────── */
.layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.main-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ── Sidebar ──────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 14px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    color: var(--sidebar-logo);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.logo-icon {
    font-size: 18px;
    color: #7ababa;
}

.sidebar-nav {
    padding: 8px 0 24px;
    flex: 1;
}

.nav-section-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--sidebar-label);
    padding: 16px 14px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 14px;
    color: var(--sidebar-text);
    font-size: 12.5px;
    border-left: 3px solid transparent;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: #d8eeee;
    text-decoration: none;
}

.nav-item.active {
    background: var(--sidebar-active);
    color: #ffffff;
    border-left-color: #7ababa;
}

.nav-icon {
    font-size: 11px;
    width: 14px;
    text-align: center;
    flex-shrink: 0;
    opacity: 0.75;
}

/* ── Top bar ──────────────────────────────────── */
.topbar {
    height: var(--topbar-height);
    background: var(--topbar-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.topbar-title {
    color: #c8dcdc;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--topbar-text);
    font-size: 12px;
}

.topbar-time { font-family: var(--font-mono); font-size: 11.5px; }
.topbar-divider { opacity: 0.3; }

.badge-superuser {
    background: var(--teal);
    color: #fff;
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 4px;
    font-weight: 600;
}

.topbar-logout {
    color: #7aacac;
    font-size: 11.5px;
    padding: 3px 8px;
    border: 1px solid rgba(122,172,172,0.3);
    border-radius: 3px;
}
.topbar-logout:hover { color: #fff; text-decoration: none; border-color: rgba(255,255,255,0.3); }

/* ── Content area ─────────────────────────────── */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* ── Dashboard grid ───────────────────────────── */
.dash-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.dash-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 14px;
    margin-bottom: 14px;
}

/* ── Cards / widgets ──────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 12px;
    background: var(--teal);
    color: #fff;
    font-weight: 600;
    font-size: 12.5px;
}

.card-header .card-meta {
    font-size: 11px;
    font-weight: 400;
    opacity: 0.8;
}

.card-body { padding: 12px; }

.card-stat {
    font-size: 28px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--teal-dark);
    line-height: 1;
}

.card-stat-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 3px;
}

/* ── Stat row ─────────────────────────────────── */
.stat-row {
    display: flex;
    gap: 14px;
    margin-bottom: 14px;
}

.stat-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 10px 16px;
    flex: 1;
    border-top: 3px solid var(--teal);
}

.stat-box.red   { border-top-color: var(--red); }
.stat-box.green { border-top-color: var(--green); }
.stat-box.orange { border-top-color: var(--orange); }

.stat-box .val {
    font-size: 22px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text);
}

.stat-box .lbl {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── Tables ───────────────────────────────────── */
.tbl-wrap {
    overflow-x: auto;
}

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

thead tr {
    background: var(--table-header);
    color: #fff;
}

thead th {
    padding: 6px 10px;
    text-align: left;
    font-weight: 600;
    font-size: 11.5px;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

tbody tr:nth-child(even) { background: var(--table-alt); }
tbody tr:hover { background: var(--table-hover); }

tbody td {
    padding: 5px 10px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

td.mono { font-family: var(--font-mono); font-size: 12px; }
td.right { text-align: right; }
td.center { text-align: center; }

/* ── Badges / pills ───────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
}

.badge-ok      { background: var(--green-bg); color: var(--green); }
.badge-warn    { background: var(--orange-bg); color: var(--orange); }
.badge-err     { background: var(--red-bg); color: var(--red); }
.badge-neutral { background: #eee; color: #555; }

.dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 4px;
}
.dot-green  { background: var(--green); }
.dot-red    { background: var(--red); }
.dot-orange { background: var(--orange); }

/* enable / tick mark */
.tick { color: var(--green); font-size: 14px; }
.cross { color: var(--red); font-size: 14px; }

/* ── Profit / loss colouring ──────────────────── */
.pos { color: var(--green); font-weight: 600; }
.neg { color: var(--red);   font-weight: 600; }

/* ── Buttons ──────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 3px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: filter 0.1s;
}
.btn:hover { filter: brightness(1.1); text-decoration: none; }

.btn-primary   { background: var(--teal);      color: #fff; }
.btn-secondary { background: #5a7a7a;           color: #fff; }
.btn-danger    { background: var(--red);        color: #fff; }
.btn-sm        { padding: 3px 8px; font-size: 11.5px; }
.btn-new       { background: var(--green);      color: #fff; }

/* ── Filter bar ───────────────────────────────── */
.filter-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 10px 14px;
    margin-bottom: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

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

.filter-group select,
.filter-group input {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 3px;
    font-size: 12.5px;
    background: var(--bg);
    color: var(--text);
    height: 28px;
}

/* ── Page header row ──────────────────────────── */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.page-head h1 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

/* ── Balance running-out widget ───────────────── */
.balance-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 12.5px;
}

.balance-row:last-child { border-bottom: none; }

.balance-row .payee { font-weight: 600; }

.balance-bar-wrap {
    width: 100px;
    height: 5px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.balance-bar {
    height: 100%;
    border-radius: 3px;
    background: var(--red);
}

/* ── Charts ───────────────────────────────────── */
.chart-wrap {
    position: relative;
    height: 180px;
}

/* ── Softswitch info table ────────────────────── */
.ss-info td:last-child { text-align: center; }

/* ── Pagination ───────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 0;
    font-size: 12px;
    color: var(--text-muted);
}

.pagination a {
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--teal);
}

.pagination a:hover { background: var(--teal-light); }
.pagination .current { padding: 3px 8px; background: var(--teal); color: #fff; border-radius: 3px; }

/* ── Form page ────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 24px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-field label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
}

.form-field input,
.form-field select,
.form-field textarea {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 3px;
    font-size: 13px;
    background: var(--surface);
    color: var(--text);
}

.form-field input:focus,
.form-field select:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 2px rgba(58,122,112,0.15);
}

.form-actions {
    margin-top: 18px;
    display: flex;
    gap: 10px;
}

/* ── Misc ─────────────────────────────────────── */
.mb-14 { margin-bottom: 14px; }
.text-right { text-align: right; }
.text-mono { font-family: var(--font-mono); }
.fw-600 { font-weight: 600; }

/* Ping issue highlight */
tr.ping-issue { background: #fff3f3 !important; }
tr.ping-issue td { color: var(--red); }
