/* ═══════════════════════════════════════════════════════════
   Visorium Backoffice — Design System
   ═══════════════════════════════════════════════════════════ */

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

:root {
    /* Brand — teal to distinguish from Portal blue */
    --color-brand:       #0D9E82;
    --color-brand-dark:  #0A876F;
    --color-brand-light: #D0EDE8;

    /* Surfaces */
    --color-bg:          #0f1923;
    --color-bg-2:        #162030;
    --color-bg-3:        #1c2a3a;
    --color-surface:     #1a3040;
    --color-surface-2:   #1f3a50;
    --color-border:      rgba(255,255,255,0.10);
    --color-border-2:    rgba(255,255,255,0.18);

    /* Text */
    --color-text:        #e8edf4;
    --color-text-muted:  #8da3be;
    --color-text-subtle: #546880;

    /* Status */
    --color-success:     #1D9E75;
    --color-success-bg:  rgba(29,158,117,0.15);
    --color-danger:      #e24b4a;
    --color-danger-bg:   rgba(226,75,74,0.15);
    --color-warning:     #EF9F27;
    --color-warning-bg:  rgba(239,159,39,0.15);
    --color-info:        #0D9E82;
    --color-info-bg:     rgba(13,158,130,0.15);

    /* Metric colors */
    --metric-blue:       #2E75B6;
    --metric-blue-bg:    rgba(46,117,182,0.15);
    --metric-green:      #1D9E75;
    --metric-green-bg:   rgba(29,158,117,0.15);
    --metric-purple:     #7F77DD;
    --metric-purple-bg:  rgba(127,119,221,0.15);
    --metric-amber:      #EF9F27;
    --metric-amber-bg:   rgba(239,159,39,0.15);

    /* Layout */
    --sidebar-w:         220px;
    --topbar-h:          52px;
    --radius-sm:         6px;
    --radius-md:         10px;
    --radius-lg:         14px;

    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.55;
    color: var(--color-text);
    background: var(--color-bg);
}

/* ── Layout ── */
.ds-layout { display: flex; min-height: 100vh; }

.ds-sidebar {
    width: var(--sidebar-w);
    background: var(--color-bg-2);
    border-right: 1px solid var(--color-border);
    display: flex; flex-direction: column; flex-shrink: 0;
    position: fixed; top: 0; left: 0;
    height: 100vh; overflow-y: auto; z-index: 100;
}

.ds-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 20px 18px 16px;
    border-bottom: 1px solid var(--color-border);
}
.ds-brand-icon { font-size: 20px; color: var(--color-brand); }
.ds-brand-name { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; }

.ds-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.ds-nav-section { margin-top: 16px; }
.ds-nav-section:first-child { margin-top: 4px; }
.ds-nav-label {
    display: block; font-size: 10px; font-weight: 600;
    letter-spacing: 0.8px; text-transform: uppercase;
    color: var(--color-text-subtle); padding: 0 8px 6px;
}
.ds-nav-section-header {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; background: none; border: none; outline: none; cursor: pointer;
    padding: 0 8px 6px; transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.ds-nav-section-header:hover { color: var(--color-text-muted); }
.ds-nav-section-header:hover .ds-nav-label { color: var(--color-text-muted); }
.ds-nav-section-header .ds-nav-label { padding: 0; }
.ds-nav-chevron { font-size: 9px; color: inherit; flex-shrink: 0; }
.ds-nav-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    text-decoration: none; font-size: 13.5px;
    transition: background 0.15s, color 0.15s;
}
.ds-nav-item:hover { background: var(--color-bg-3); color: var(--color-text); }
.ds-nav-item.active {
    background: var(--color-brand-light);
    color: var(--color-brand-dark);
    font-weight: 600;
}
.ds-nav-icon { font-size: 13px; width: 16px; text-align: center; }

.ds-user-info { display: flex; align-items: center; gap: 10px; }
.ds-user-avatar {
    width: 32px; height: 32px;
    background: var(--color-brand); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.ds-user-details { display: flex; flex-direction: column; }
.ds-user-name { font-size: 13px; font-weight: 600; color: var(--color-text); }
.ds-user-tenant { font-size: 11px; color: var(--color-text-muted); }
.ds-logout-btn {
    width: 100%; padding: 7px;
    background: transparent; border: 1px solid var(--color-border);
    border-radius: var(--radius-sm); color: var(--color-text-muted);
    font-size: 13px; cursor: pointer; transition: background 0.15s;
}
.ds-logout-btn:hover { background: var(--color-danger-bg); color: var(--color-danger); }

.ds-main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }
.ds-topbar {
    height: var(--topbar-h); background: var(--color-bg-2);
    border-bottom: 1px solid var(--color-border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 28px; position: sticky; top: 0; z-index: 50;
}
.ds-breadcrumb { font-size: 13px; color: var(--color-text-muted); }
.ds-plan-badge {
    font-size: 11px; font-weight: 600; padding: 3px 10px;
    background: var(--color-brand-light); color: var(--color-brand-dark); border-radius: 20px;
}
.ds-content { padding: 28px; max-width: 1280px; }

/* ── Page header ── */
.ds-page-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.ds-page-title { font-size: 22px; font-weight: 700; line-height: 1.2; }
.ds-page-title:focus { outline: none; }
.ds-page-subtitle { display: block; font-size: 13px; color: var(--color-text-muted); margin-top: 3px; }
.ds-section-title { font-size: 15px; font-weight: 600; color: var(--color-text); }

/* ── Buttons ── */
.ds-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: var(--radius-sm);
    font-size: 13.5px; font-weight: 500; cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s, opacity 0.15s, transform 0.1s;
    text-decoration: none; line-height: 1;
}
.ds-btn:active { transform: scale(0.98); }
.ds-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ds-btn-primary { background: var(--color-brand); color: #fff; border-color: var(--color-brand-dark); }
.ds-btn-primary:hover:not(:disabled) { background: var(--color-brand-dark); }
.ds-btn-ghost { background: transparent; color: var(--color-text-muted); border-color: var(--color-border); }
.ds-btn-ghost:hover:not(:disabled) { background: var(--color-bg-3); color: var(--color-text); }
.ds-btn-danger { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }
.ds-btn-danger:hover:not(:disabled) { opacity: 0.85; }
.ds-btn-sm { padding: 5px 12px; font-size: 12.5px; }
.ds-btn-full { width: 100%; justify-content: center; }

.ds-btn-icon {
    background: transparent; border: none; cursor: pointer;
    color: var(--color-text-muted); font-size: 14px;
    padding: 4px 6px; border-radius: var(--radius-sm);
    transition: background 0.15s, color 0.15s;
}
.ds-btn-icon:hover { background: var(--color-bg-3); color: var(--color-text); }
.ds-btn-icon--danger:hover { background: var(--color-danger-bg); color: var(--color-danger); }

/* ── Forms ── */
.ds-form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.ds-label { font-size: 12.5px; font-weight: 500; color: var(--color-text-muted); }
.ds-input {
    background: var(--color-bg-3); border: 1px solid var(--color-border);
    border-radius: var(--radius-sm); padding: 9px 12px;
    color: var(--color-text); font-size: 14px; width: 100%;
    transition: border-color 0.15s;
}
.ds-input:focus { outline: none; border-color: var(--color-brand); }
.ds-input::placeholder { color: var(--color-text-subtle); }
select.ds-input { cursor: pointer; }

/* ── Metric cards ── */
.ds-metric-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px; margin-bottom: 24px;
}
.ds-metric-card {
    background: var(--color-bg-2); border: 1px solid var(--color-border);
    border-radius: var(--radius-md); padding: 18px 20px;
    display: flex; align-items: center; gap: 16px;
}
.ds-metric-icon { font-size: 22px; flex-shrink: 0; }
.ds-metric-value { display: block; font-size: 26px; font-weight: 700; line-height: 1; }
.ds-metric-title { display: block; font-size: 12px; color: var(--color-text-muted); margin-top: 4px; }
.ds-metric-card--blue   { border-left: 3px solid var(--metric-blue); }
.ds-metric-card--blue   .ds-metric-icon  { color: var(--metric-blue); }
.ds-metric-card--blue   .ds-metric-value { color: var(--metric-blue); }
.ds-metric-card--green  { border-left: 3px solid var(--metric-green); }
.ds-metric-card--green  .ds-metric-icon  { color: var(--metric-green); }
.ds-metric-card--green  .ds-metric-value { color: var(--metric-green); }
.ds-metric-card--purple { border-left: 3px solid var(--metric-purple); }
.ds-metric-card--purple .ds-metric-icon  { color: var(--metric-purple); }
.ds-metric-card--purple .ds-metric-value { color: var(--metric-purple); }
.ds-metric-card--amber  { border-left: 3px solid var(--metric-amber); }
.ds-metric-card--amber  .ds-metric-icon  { color: var(--metric-amber); }
.ds-metric-card--amber  .ds-metric-value { color: var(--metric-amber); }

/* ── Tables ── */
.ds-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.ds-table th {
    text-align: left; padding: 10px 12px;
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--color-text-muted); border-bottom: 1px solid var(--color-border);
}
.ds-table td { padding: 11px 12px; border-bottom: 1px solid var(--color-border); }
.ds-table tr:last-child td { border-bottom: none; }
.ds-table tr:hover td { background: var(--color-bg-3); }
.ds-table--full { width: 100%; }
.ds-td-name { font-weight: 500; }
.ds-td-muted { color: var(--color-text-muted); }
.ds-row-inactive td { opacity: 0.5; }
.ds-monospace { font-family: 'Courier New', Courier, monospace; }

/* ── Status & badges ── */
.ds-status-pill {
    display: inline-block; padding: 3px 10px;
    border-radius: 20px; font-size: 11px; font-weight: 600;
}
.ds-status-pill.active   { background: var(--color-success-bg); color: var(--color-success); }
.ds-status-pill.inactive { background: var(--color-bg-3); color: var(--color-text-subtle); }

/* ── Alerts ── */
.ds-alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13.5px; margin: 12px 0; }
.ds-alert-error   { background: var(--color-danger-bg); color: var(--color-danger); border: 1px solid var(--color-danger); }
.ds-alert-success { background: var(--color-success-bg); color: var(--color-success); border: 1px solid var(--color-success); }
.ds-error-text { color: var(--color-danger); font-size: 13px; margin: 8px 0; }

/* ── Modal ── */
.ds-modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; padding: 20px;
}
.ds-modal {
    background: var(--color-bg-2); border: 1px solid var(--color-border-2);
    border-radius: var(--radius-lg); width: 100%; max-width: 540px;
    max-height: 90vh; overflow-y: auto;
    box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}
.ds-modal--sm { max-width: 400px; }
.ds-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px 16px; border-bottom: 1px solid var(--color-border);
}
.ds-modal-title { font-size: 16px; font-weight: 600; }
.ds-modal-close {
    background: none; border: none; cursor: pointer;
    color: var(--color-text-muted); font-size: 16px;
    padding: 4px 6px; border-radius: var(--radius-sm);
}
.ds-modal-close:hover { background: var(--color-bg-3); }
.ds-modal-body { padding: 20px 24px; }
.ds-modal-footer {
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 16px 24px 20px; border-top: 1px solid var(--color-border);
}
.ds-confirm-message { color: var(--color-text-muted); font-size: 14px; line-height: 1.6; }

/* ── Loading ── */
.ds-loading { display: flex; align-items: center; justify-content: center; padding: 60px; }
.ds-spinner {
    width: 28px; height: 28px;
    border: 3px solid var(--color-border); border-top-color: var(--color-brand);
    border-radius: 50%; animation: spin 0.7s linear infinite;
}
.ds-spinner-sm {
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff;
    border-radius: 50%; animation: spin 0.7s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ds-empty { color: var(--color-text-muted); font-size: 14px; text-align: center; padding: 40px 0; }

/* ── Login ── */
.ds-login-wrapper {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: var(--color-bg); padding: 20px;
}
.ds-login-card {
    background: var(--color-bg-2); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); padding: 40px;
    width: 100%; max-width: 400px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.4);
}
.ds-login-brand { text-align: center; margin-bottom: 28px; }
.ds-brand-icon-lg { font-size: 36px; display: block; margin-bottom: 8px; color: var(--color-brand); }
.ds-login-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.ds-login-subtitle { font-size: 13px; color: var(--color-text-muted); }

/* ── Misc ── */
.not-found { padding: 60px; text-align: center; color: var(--color-text-muted); }
.not-found h2 { font-size: 22px; font-weight: 700; margin-bottom: 12px; }
.not-found a { color: var(--color-brand); }

#blazor-error-ui {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--color-danger-bg); border-top: 1px solid var(--color-danger);
    padding: 12px 24px; display: none; align-items: center; gap: 16px;
    font-size: 13.5px; color: var(--color-danger); z-index: 9999;
}
#blazor-error-ui.blazor-error-boundary { display: flex; }
.dismiss { cursor: pointer; margin-left: auto; }
