/* Management — Orion Dark Design System
   Tokens + components. Class names are stable; values are themed here. */

:root {
    --ori-bg: #0f0f0f;            /* page background */
    --ori-surface: #1a1a1a;       /* cards / panels */
    --ori-surface-2: #111;        /* inputs, inset rows */
    --ori-border: #2a2a2a;
    --ori-border-soft: #232323;
    --ori-accent: #4a8eff;
    --ori-accent-hover: #3a7be0;
    --ori-danger: #e74c3c;
    --ori-danger-hover: #c0392b;
    --ori-text: #f0f0f0;
    --ori-text-2: #b6bcc6;
    --ori-text-3: #8a8f98;
    --ori-text-4: #5d626b;
    --ori-success: #66bb6a;
    --ori-warning: #ffb74d;
    --ori-radius: 12px;
    --ori-radius-sm: 8px;
    --ori-shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.18);
    --ori-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* ---------- Base overrides (after bootstrap-night) ---------- */
body {
    background: var(--ori-bg);
    font-family: var(--ori-font);
    color: var(--ori-text-2);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::selection { background: rgba(74,142,255,.3); }

* { scrollbar-width: thin; scrollbar-color: #333 transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #333; border-radius: 5px; border: 2px solid var(--ori-bg); }
*::-webkit-scrollbar-track { background: transparent; }

a { color: var(--ori-accent); text-decoration: none; }
a:hover { color: #79aaff; }

/* ---------- Navbar ---------- */
.mgmt-navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15, 15, 15, 0.85) !important;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--ori-border-soft) !important;
    padding: 0.65rem 0;
}

.mgmt-navbar .navbar-brand {
    display: inline-flex;
    align-items: center;
    color: #fff !important;
    font-weight: 650;
    font-size: 1rem;
    letter-spacing: 0.01em;
}

.mgmt-navbar .nav-link {
    color: var(--ori-text-3) !important;
    font-size: 0.86rem;
    font-weight: 500;
    padding: 0.35rem 0.85rem !important;
    border-radius: 7px;
    transition: color 0.15s ease, background 0.15s ease;
}

.mgmt-navbar .nav-link:hover {
    color: #fff !important;
    background: rgba(255,255,255,0.05);
}

.mgmt-navbar .nav-link.active {
    color: #fff !important;
    background: rgba(74,142,255,0.14);
}

.mgmt-navbar .navbar-toggler { border-color: #3a3a3a; }
.mgmt-navbar .navbar-toggler-icon { filter: invert(0.7); }

/* ---------- Page layout ---------- */
.mgmt-content {
    padding: 2.25rem 1.25rem 3rem;
    max-width: 1080px;
    margin: 0 auto;
}

/* ---------- Page titles (left-aligned, dashboard style) ---------- */
.mgmt-page-title {
    font-size: 1.45rem;
    font-weight: 650;
    letter-spacing: -0.015em;
    color: #fff;
    text-align: left;
    margin: 0 0 0.3rem;
}

.mgmt-page-subtitle {
    font-size: 0.875rem;
    color: var(--ori-text-3);
    text-align: left;
    margin: 0 0 1.75rem;
}

.mgmt-section-title {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.005em;
    color: var(--ori-text);
    text-align: left;
    margin: 2rem 0 1rem;
}

.mgmt-divider {
    border: none;
    border-top: 1px solid var(--ori-border-soft);
    margin: 2rem 0;
}

/* ---------- Card grid ---------- */
.mgmt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.mgmt-card {
    padding: 1.4rem 1.5rem;
    background: var(--ori-surface);
    border: 1px solid var(--ori-border);
    border-radius: var(--ori-radius);
    text-align: left;
    transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.mgmt-card:hover {
    border-color: #3a3f47;
    box-shadow: var(--ori-shadow);
}

.mgmt-card h3 {
    margin: 0 0 0.35rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ori-text);
}

.mgmt-card p {
    margin: 0 0 1rem;
    font-size: 0.82rem;
    color: var(--ori-text-3);
    line-height: 1.55;
}

/* ---------- Buttons ---------- */
.mgmt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.15rem;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    line-height: 1.2;
    color: #fff;
    background: var(--ori-accent);
    border: 1px solid transparent;
    border-radius: var(--ori-radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,.3);
}

.mgmt-btn:hover {
    background: var(--ori-accent-hover);
    color: #fff;
    text-decoration: none;
}

.mgmt-btn:active { transform: translateY(1px); }

.mgmt-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(74,142,255,.35);
}

.mgmt-btn-secondary {
    background: transparent;
    border: 1px solid #3a3a3a;
    color: var(--ori-text-2);
    box-shadow: none;
}

.mgmt-btn-secondary:hover {
    border-color: var(--ori-accent);
    color: #fff;
    background: rgba(74,142,255,0.08);
}

.mgmt-btn-danger { background: var(--ori-danger); }
.mgmt-btn-danger:hover { background: var(--ori-danger-hover); }

.mgmt-btn-sm {
    padding: 0.38rem 0.85rem;
    font-size: 0.8rem;
}

/* ---------- Forms ---------- */
.mgmt-form {
    max-width: 520px;
}

.mgmt-field { margin-bottom: 1.15rem; }

.mgmt-field label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--ori-text-3);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.mgmt-field input[type="text"],
.mgmt-field input[type="email"],
.mgmt-field input[type="password"],
.mgmt-field input[type="number"],
.mgmt-field textarea,
.mgmt-field select,
.mgmt-field .form-control,
.mgmt-panel input[type="text"],
.mgmt-panel input[type="email"],
.mgmt-panel input[type="password"],
.mgmt-panel input[type="number"],
.mgmt-panel textarea,
.mgmt-panel select {
    display: block;
    width: 100%;
    padding: 0.65rem 0.85rem;
    font-size: 0.92rem;
    color: var(--ori-text);
    background: var(--ori-surface-2);
    border: 1px solid #2e2e2e;
    border-radius: var(--ori-radius-sm);
    outline: none;
    font-family: inherit;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.mgmt-field select,
.mgmt-panel select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23888' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 14px 10px;
    padding-right: 2.2rem;
}

.mgmt-field input:focus,
.mgmt-field textarea:focus,
.mgmt-field select:focus,
.mgmt-field .form-control:focus,
.mgmt-panel input:focus,
.mgmt-panel textarea:focus,
.mgmt-panel select:focus {
    color: var(--ori-text);
    background-color: var(--ori-surface-2);
    border-color: var(--ori-accent);
    box-shadow: 0 0 0 3px rgba(74, 142, 255, 0.15);
}

.mgmt-field input::placeholder,
.mgmt-field textarea::placeholder,
.mgmt-panel input::placeholder,
.mgmt-panel textarea::placeholder {
    color: #555;
}

.mgmt-field textarea { resize: vertical; min-height: 80px; }

/* ---------- Checkbox ---------- */
.mgmt-checkbox {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-bottom: 0.9rem;
}

.mgmt-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--ori-accent);
    cursor: pointer;
    flex: 0 0 auto;
}

.mgmt-checkbox label {
    font-size: 0.85rem;
    color: var(--ori-text-2);
    margin: 0;
    cursor: pointer;
}

input[type="checkbox"] { accent-color: var(--ori-accent); }

/* ---------- App cards ---------- */
.mgmt-app-card {
    padding: 1.4rem 1.5rem;
    background: var(--ori-surface);
    border: 1px solid var(--ori-border);
    border-radius: var(--ori-radius);
    text-align: left;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.mgmt-app-card:hover {
    border-color: #3a3f47;
    box-shadow: var(--ori-shadow);
}

.mgmt-app-card img {
    max-width: 200px;
    max-height: 160px;
    border-radius: var(--ori-radius-sm);
    margin-bottom: 0.75rem;
}

.mgmt-app-card h4 {
    margin: 0 0 0.4rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ori-text);
}

.mgmt-app-card p {
    margin: 0 0 0.75rem;
    font-size: 0.82rem;
    color: var(--ori-text-3);
    line-height: 1.5;
}

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

/* ---------- System accounts (legacy rows) ---------- */
.mgmt-sys-account {
    padding: 1rem 1.25rem;
    background: var(--ori-surface);
    border: 1px solid var(--ori-border);
    border-radius: var(--ori-radius-sm);
    margin-bottom: 0.75rem;
}

.mgmt-sys-account h5 {
    font-size: 0.82rem;
    color: var(--ori-text-2);
    word-break: break-all;
    margin: 0 0 0.65rem;
}

.mgmt-sys-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* ---------- Permission items ---------- */
.mgmt-permission-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.mgmt-permission-item {
    padding: 1rem 1.15rem;
    background: var(--ori-surface-2);
    border: 1px solid var(--ori-border);
    border-radius: var(--ori-radius-sm);
}

.mgmt-permission-item h4 {
    margin: 0 0 0.3rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ori-text);
}

.mgmt-permission-item p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--ori-text-3);
    line-height: 1.45;
}

/* ---------- Info / meta text ---------- */
.mgmt-info {
    font-size: 0.85rem;
    color: var(--ori-text-3);
    margin: 0.5rem 0;
}

.mgmt-info b { color: var(--ori-text-2); }

/* ---------- Alerts ---------- */
.mgmt-alert-danger {
    padding: 0.7rem 0.95rem;
    font-size: 0.85rem;
    color: #ef9a9a;
    background: rgba(239, 83, 80, 0.08);
    border: 1px solid rgba(239, 83, 80, 0.25);
    border-radius: var(--ori-radius-sm);
    margin-bottom: 1rem;
}

.mgmt-alert-success {
    padding: 0.7rem 0.95rem;
    font-size: 0.85rem;
    color: #a5d6a7;
    background: rgba(76, 175, 80, 0.1);
    border: 1px solid rgba(102, 187, 106, 0.3);
    border-radius: var(--ori-radius-sm);
    margin-bottom: 1rem;
}

/* ---------- Expandable sections ---------- */
.mgmt-expand-trigger { margin-bottom: 1rem; }

/* ---------- App header (permission pages) ---------- */
.mgmt-app-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.mgmt-app-header img {
    display: block;
    margin: 0 auto 0.75rem;
    max-width: 110px;
    max-height: 110px;
    border-radius: var(--ori-radius);
}

.mgmt-app-header h2 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: #fff;
}

/* ---------- Requirement rows ---------- */
.mgmt-requirement-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.2rem;
    border-bottom: 1px solid var(--ori-border-soft);
    font-size: 0.88rem;
    color: var(--ori-text-2);
}

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

/* ---------- Footer ---------- */
.mgmt-footer {
    border-top: 1px solid var(--ori-border-soft) !important;
    color: var(--ori-text-4);
    font-size: 0.78rem;
    padding: 1.25rem 0 1.75rem;
    background: transparent;
}

/* ---------- TOTP container ---------- */
.mgmt-totp { text-align: center; margin: 1rem 0; }
.mgmt-totp canvas, .mgmt-totp img { border-radius: var(--ori-radius-sm); margin-bottom: 0.75rem; }

/* ---------- Settings layout (panels) ---------- */
.mgmt-settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
    align-items: start;
}

.mgmt-panel {
    background: var(--ori-surface);
    border: 1px solid var(--ori-border);
    border-radius: var(--ori-radius);
    padding: 1.5rem;
    transition: border-color 0.15s ease;
}

.mgmt-panel-wide { grid-column: 1 / -1; }

.mgmt-panel-head { margin-bottom: 1.15rem; }

.mgmt-panel-head h3 {
    margin: 0 0 0.3rem;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.005em;
    color: var(--ori-text);
}

.mgmt-panel-head p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--ori-text-3);
    line-height: 1.5;
}

.mgmt-panel-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-top: 1.15rem;
}

/* ---------- Row lists ---------- */
.mgmt-row-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mgmt-row {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 0.95rem;
    background: var(--ori-surface-2);
    border: 1px solid #242424;
    border-radius: var(--ori-radius-sm);
    transition: border-color 0.15s ease, background 0.15s ease;
}

.mgmt-row + .mgmt-row { margin-top: 0.5rem; }
.mgmt-row-list .mgmt-row + .mgmt-row { margin-top: 0; }

.mgmt-row:hover {
    border-color: #363636;
    background: #141414;
}

.mgmt-row-icon {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1f1f1f;
    border: 1px solid #2e2e2e;
    border-radius: var(--ori-radius-sm);
    font-size: 1rem;
}

.mgmt-row-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
}

.mgmt-row-title {
    font-size: 0.88rem;
    font-weight: 550;
    color: var(--ori-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mgmt-row-sub {
    font-size: 0.74rem;
    color: var(--ori-text-4);
}

.mgmt-row-actions {
    display: flex;
    gap: 0.35rem;
    flex: 0 0 auto;
    align-items: center;
}

/* ---------- Badges & pills ---------- */
.mgmt-badge {
    display: inline-block;
    padding: 0.12rem 0.5rem;
    font-size: 0.66rem;
    font-weight: 600;
    color: #9ab8e8;
    background: rgba(74, 142, 255, 0.12);
    border-radius: 10px;
    vertical-align: middle;
    margin-left: 0.35rem;
    letter-spacing: 0.02em;
}

.mgmt-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.8rem;
    font-size: 0.73rem;
    font-weight: 600;
    border-radius: 999px;
    background: #1f1f1f;
    border: 1px solid #2e2e2e;
    color: var(--ori-text-3);
    white-space: nowrap;
}

.mgmt-pill-on {
    background: rgba(76, 175, 80, 0.12);
    border-color: rgba(102, 187, 106, 0.25);
    color: var(--ori-success);
}

.mgmt-pill-off {
    background: rgba(255, 152, 0, 0.1);
    border-color: rgba(255, 183, 77, 0.25);
    color: var(--ori-warning);
}

/* ---------- Icon buttons ---------- */
.mgmt-icon-btn {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid #333;
    border-radius: 7px;
    color: var(--ori-text-3);
    font-size: 0.85rem;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.mgmt-icon-btn:hover {
    border-color: var(--ori-accent);
    color: #fff;
    background: rgba(74,142,255,0.08);
}

.mgmt-icon-btn-danger:hover {
    border-color: var(--ori-danger);
    color: var(--ori-danger);
    background: rgba(231,76,60,0.08);
}

/* ---------- Tables ---------- */
.mgmt-content table {
    border-color: var(--ori-border);
}

/* ---------- Toasts ---------- */
.ori-toast-wrap {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-end;
}

.ori-toast {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 1rem;
    background: var(--ori-surface);
    border: 1px solid var(--ori-border);
    border-radius: 10px;
    box-shadow: var(--ori-shadow);
    color: var(--ori-text);
    font-size: 0.84rem;
    font-family: var(--ori-font);
    animation: oriToastIn 0.2s ease;
    max-width: 380px;
}

.ori-toast.ori-toast-out {
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.ori-toast-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.ori-toast-success .ori-toast-dot { background: var(--ori-success); }
.ori-toast-error .ori-toast-dot { background: #ef5350; }
.ori-toast-info .ori-toast-dot { background: var(--ori-accent); }
.ori-toast-warning .ori-toast-dot { background: var(--ori-warning); }

@keyframes oriToastIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .mgmt-settings-grid { grid-template-columns: 1fr; }
    .mgmt-grid { grid-template-columns: 1fr; }
    .mgmt-permission-grid { grid-template-columns: 1fr; }
    .mgmt-sys-actions { flex-direction: column; align-items: stretch; }
    .mgmt-app-actions { flex-direction: column; }
    .mgmt-content { padding: 1.5rem 1rem 2.5rem; }
}
