/* Platform owner console. Deliberately its own stylesheet: this app is not a
   tenant surface and should not inherit the customer theme. */
:root {
    --bg: #0f172a;
    --panel: #ffffff;
    --ink: #1e293b;
    --muted: #64748b;
    --line: #e2e8f0;
    --brand: #4f46e5;
    --brand-dark: #4338ca;
    --ok: #059669;
    --warn: #d97706;
    --bad: #dc2626;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Vazirmatn, system-ui, sans-serif;
    background: #f1f5f9;
    color: var(--ink);
    font-size: 14px;
}

h1 { font-size: 1.4rem; margin: 0 0 .25rem; }
.page-sub { color: var(--muted); margin: 0 0 1.25rem; line-height: 1.8; }
.hint { color: var(--muted); font-size: .78rem; margin-top: .15rem; }
code { background: #f1f5f9; padding: .1rem .35rem; border-radius: 4px; font-size: .8rem; }

/* ---- Shell ---- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 230px;
    flex: 0 0 230px;
    background: var(--bg);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    padding: 1.25rem 0;
}

.brand { font-weight: 700; color: #fff; padding: 0 1.25rem 1.25rem; font-size: 1.05rem; }

.nav-item {
    display: block;
    padding: .65rem 1.25rem;
    color: #cbd5e1;
    text-decoration: none;
    border-inline-start: 3px solid transparent;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.active { background: rgba(79, 70, 229, .25); color: #fff; border-inline-start-color: var(--brand); }

.sidebar-foot { margin-top: auto; padding: 1rem 1.25rem 0; border-top: 1px solid rgba(255, 255, 255, .1); }
.who { font-size: .85rem; margin-bottom: .5rem; color: #94a3b8; }

.content { flex: 1; padding: 1.75rem; min-width: 0; }

/* ---- Cards & toolbar ---- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.card-body { padding: 1.25rem; }
.toolbar { display: flex; gap: .6rem; margin-bottom: 1rem; flex-wrap: wrap; }
.center-state { padding: 2.5rem; text-align: center; color: var(--muted); }
.quick-links { display: flex; gap: .6rem; margin-top: 1.5rem; flex-wrap: wrap; }

/* ---- Stats ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; }
.stat-value { font-size: 1.35rem; font-weight: 700; }
.stat-label { color: var(--muted); font-size: .82rem; margin-top: .3rem; }

/* ---- Tables ---- */
.table-scroll { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.table th, .table td { padding: .7rem .85rem; text-align: right; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { background: #f8fafc; font-weight: 600; color: var(--muted); font-size: .8rem; }
.table tr:last-child td { border-bottom: none; }
.row-muted { opacity: .55; }
.actions { display: flex; gap: .35rem; flex-wrap: wrap; }

/* ---- Breadcrumbs ---- */
.crumbs { font-size: .82rem; color: var(--muted); margin-bottom: .75rem; }
.crumbs a { color: var(--brand); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

/* ---- Usage meters ---- */
.usage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.meter { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.meter-head { display: flex; justify-content: space-between; gap: .5rem; font-size: .85rem; margin-bottom: .5rem; }
.meter-figure { color: var(--muted); }
.meter-track { height: 7px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
.meter-fill { height: 100%; background: var(--brand); border-radius: 999px; }
.meter-fill.meter-warn { background: var(--warn); }
.meter-fill.meter-bad { background: var(--bad); }

/* ---- Tenant chips (a user's memberships) ---- */
.tenant-chip {
    display: inline-block;
    padding: .12rem .5rem;
    margin: 0 0 .2rem .3rem;
    border-radius: 999px;
    font-size: .72rem;
    background: #e0e7ff;
    color: var(--brand-dark);
    text-decoration: none;
}
.tenant-chip:hover { background: #c7d2fe; }
.tenant-chip.chip-off { background: #e2e8f0; color: var(--muted); }

/* ---- Badges ---- */
.badge { display: inline-block; padding: .12rem .5rem; border-radius: 999px; font-size: .72rem; background: #e2e8f0; color: #475569; margin-inline-start: .3rem; }
.badge-ok { background: #d1fae5; color: var(--ok); }
.badge-warn { background: #fef3c7; color: var(--warn); }
.badge-bad { background: #fee2e2; color: var(--bad); }
.badge-info { background: #e0e7ff; color: var(--brand-dark); }

/* ---- Forms ---- */
.field { margin-bottom: .9rem; flex: 1; min-width: 0; }
.field label { display: block; margin-bottom: .3rem; font-size: .82rem; color: var(--muted); }
.form-row { display: flex; gap: .9rem; flex-wrap: wrap; }
.checks { display: flex; flex-direction: column; gap: .5rem; justify-content: center; }
.checks label { color: var(--ink); }
.section-label { font-weight: 600; margin: 1.1rem 0 .6rem; padding-bottom: .35rem; border-bottom: 1px solid var(--line); }

.input {
    width: 100%;
    padding: .55rem .7rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-family: inherit;
    font-size: .9rem;
    background: #fff;
    color: var(--ink);
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
.search { max-width: 320px; }

/* ---- Buttons ---- */
.btn {
    padding: .55rem 1rem;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: .87rem;
    background: #e2e8f0;
    color: var(--ink);
    text-decoration: none;
    display: inline-block;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: .32rem .6rem; font-size: .78rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { background: #f1f5f9; }
.btn-danger { background: transparent; border-color: #fecaca; color: var(--bad); }
.btn-danger:hover:not(:disabled) { background: #fef2f2; }

/* ---- Alerts ---- */
.alert { padding: .7rem .9rem; border-radius: 8px; margin-bottom: 1rem; font-size: .87rem; }
.alert-error { background: #fef2f2; color: var(--bad); border: 1px solid #fecaca; }
.alert-ok { background: #ecfdf5; color: var(--ok); border: 1px solid #a7f3d0; }

/* ---- Modal ---- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 40; }
.modal {
    position: fixed;
    z-index: 50;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(720px, calc(100vw - 2rem));
    max-height: calc(100vh - 3rem);
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border-radius: var(--radius);
    box-shadow: 0 20px 45px rgba(15, 23, 42, .25);
}
.modal-sm { width: min(430px, calc(100vw - 2rem)); }
.modal-head { padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); font-weight: 600; }
.modal-body { padding: 1.25rem; overflow-y: auto; }
.modal-foot { padding: .9rem 1.25rem; border-top: 1px solid var(--line); display: flex; gap: .6rem; justify-content: flex-start; }

/* ---- Login ---- */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; width: 100%; }
.login-card { width: min(390px, calc(100vw - 2rem)); }
.login-title { font-size: 1.2rem; margin: 0 0 .25rem; }
.login-sub { color: var(--muted); margin: 0 0 1.25rem; font-size: .87rem; }

@media (max-width: 760px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; flex: none; }
    .sidebar nav { display: flex; flex-wrap: wrap; }
    .sidebar-foot { margin-top: 1rem; }
    .content { padding: 1rem; }
}
