/* ============================================================
   Carpenter Design System
   Monitoring Dashboard — exact token match from Figma vOnY1Im7w0S2nwmx4eSTvp
   ============================================================ */

/* Google Fonts — Funnel Sans */
@import url('https://fonts.googleapis.com/css2?family=Funnel+Sans:wght@300;400;500;600;700&display=swap');

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
    /* Page / surface colors */
    --c-bg:              #f9fbfc;   /* page canvas */
    --c-white:           #ffffff;   /* cards, sidebar, topbar */
    --c-border:          #e5e7eb;   /* card & panel borders */
    --c-border-light:    #f3f4f6;   /* internal dividers */
    --c-border-input:    #d1d5db;   /* input / button borders */

    /* Text scale */
    --c-text-900:        #080808;   /* KPI big numbers */
    --c-text-800:        #1f2937;   /* headings, primary text */
    --c-text-700:        #374151;   /* nav items, body */
    --c-text-600:        #4b5563;   /* subtitle */
    --c-text-500:        #6b7280;   /* secondary, table headers */
    --c-text-400:        #9ca3af;   /* muted, group labels */
    --c-text-300:        #afafaf;   /* very muted labels */

    /* Blue — primary accent */
    --c-blue:            #3b82f6;
    --c-blue-hover:      #2563eb;
    --c-blue-active:     #1e40af;   /* active nav text */
    --c-blue-bg:         #eff6ff;   /* active nav background */
    --c-blue-border:     #bfdbfe;   /* active nav border */

    /* Status */
    --c-green:           #22c55e;
    --c-green-dark:      #16a34a;
    --c-amber:           #f59e0b;
    --c-amber-dark:      #d97706;
    --c-red:             #dc2626;
    --c-red-dark:        #b91c1c;

    /* Component aliases — used in instances/list.html and other newer templates */
    --c-text-muted:      #9ca3af;   /* alias for --c-text-400 */
    --c-text-primary:    #1f2937;   /* alias for --c-text-800 */
    --c-text-secondary:  #4b5563;   /* alias for --c-text-600 */

    /* Legacy aliases used in templates — mapped to Carpenter equivalents */
    --color-main:        #1f2937;
    --color-orange:      #3b82f6;
    --color-green:       #22c55e;
    --color-red:         #dc2626;
    --color-gray1:       #6b7280;
    --color-gray2:       #e5e7eb;
    --color-gray3:       #f3f4f6;
    --color-cream:       #e5e7eb;
    --color-white:       #ffffff;
    --color-bg:          #f9fbfc;
    --color-main-5:      rgba(31, 41, 55, 0.04);
    --color-main-8:      rgba(31, 41, 55, 0.07);
    --color-main-15:     rgba(31, 41, 55, 0.12);

    /* Border radius */
    --radius-card:   16px;
    --radius-btn:    8px;
    --radius-md:     12px;
    --radius-sm:     8px;
    --radius-xs:     6px;

    /* Shadow */
    --shadow-card:   0px 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-sm:     0px 1px 3px rgba(0, 0, 0, 0.04);

    /* Layout */
    --sidebar-width: 240px;
    --topbar-height: 64px;
}


/* ── Base ──────────────────────────────────────────────────── */
*, *::before, *::after {
    font-family: 'Funnel Sans', sans-serif;
    box-sizing: border-box;
}

body {
    background-color: var(--c-bg);
    color: var(--c-text-700);
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
}

a, button {
    transition: all 0.15s ease;
}


/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--c-white);
    border-right: 1px solid var(--c-border);
    position: fixed;
    left: 0;
    top: 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    padding: 24px 12px 32px;
    overflow-y: auto;
}

/* Logo — "Odoo." 16px SemiBold */
.sidebar-logo {
    font-weight: 600;
    font-size: 16px;
    line-height: 1;
    color: var(--c-text-800);
    padding: 0 16px 20px;
    flex-shrink: 0;
    letter-spacing: -0.5px;
}

.sidebar-logo .dot {
    color: var(--c-blue);
}

/* Nav list */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0;
    flex: 1;
}

/* Section group label — WORKER, SETTINGS, etc. */
.sidebar-section-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--c-text-400);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 10px 16px;
    margin-top: 4px;
}

/* Nav item — 40px tall, 10px radius */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid transparent;
    color: var(--c-text-700);
    font-weight: 500;
    font-size: 13px;
    text-decoration: none;
    white-space: nowrap;
}

.sidebar-link:hover {
    background: var(--c-blue-bg);
    color: var(--c-blue-active);
}

/* Active — blue-50 bg, blue-200 border, blue-800 text */
.sidebar-link.active {
    background: var(--c-blue-bg);
    border-color: var(--c-blue-border);
    color: var(--c-blue-active);
}

/* Icons — 18×18 */
.sidebar-link svg,
.sidebar-link .sidebar-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px 4px 0;
    margin-top: 8px;
    border-top: 1px solid var(--c-border);
}


/* ── Main content area ─────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}


/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
    display: flex;
    align-items: center;
    background: var(--c-white);
    border-bottom: 1px solid var(--c-border);
    padding: 0 24px;
    height: var(--topbar-height);
    gap: 16px;
    flex-shrink: 0;
}

/* Page title in topbar */
.topbar-title {
    font-weight: 600;
    font-size: 15px;
    line-height: 1;
    color: var(--c-text-800);
    white-space: nowrap;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Search bar — bg #f9fbfc, 1px border, 16px radius */
.search-bar {
    background: var(--c-bg);
    border: 1px solid var(--c-border-input);
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    height: 38px;
    min-width: 220px;
}

.search-bar input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 12px;
    font-weight: 400;
    font-family: 'Funnel Sans', sans-serif;
    color: var(--c-text-700);
    width: 100%;
}

.search-bar input::placeholder {
    color: var(--c-text-500);
}

.search-bar svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--c-text-500);
}

/* Topbar icon buttons — 36×36, ghost */
.topbar-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--c-text-500);
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}

.topbar-icon-btn:hover {
    background: var(--c-bg);
    color: var(--c-text-800);
}

.topbar-icon-btn svg {
    width: 20px;
    height: 20px;
}

/* User display — right of topbar, after a divider */
.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 12px;
    border-left: 1px solid var(--c-border);
    margin-left: 4px;
    border-radius: 0;
    transition: background 0.15s ease;
}

/* When topbar-user is used as a pd-toggle button */
.topbar-user-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    transition: background 0.15s ease;
}

.topbar-user-toggle:hover {
    background: var(--c-bg);
}

/* Avatar — 33×33 circle */
.topbar-avatar {
    width: 33px;
    height: 33px;
    border-radius: 50%;
    background: var(--c-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 500;
    font-size: 14px;
    flex-shrink: 0;
}

.topbar-user-info {
    display: flex;
    flex-direction: column;
}

/* Name — 13px Medium #1f2937 */
.topbar-user-name {
    font-weight: 500;
    font-size: 13px;
    line-height: 1.2;
    color: var(--c-text-800);
    white-space: nowrap;
}

/* Role — 11px Regular #6b7280 */
.topbar-user-role {
    font-weight: 400;
    font-size: 11px;
    line-height: 1.2;
    color: var(--c-text-500);
    white-space: nowrap;
}

/* Notification badge dot */
.notif-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background: var(--c-red);
    border-radius: 50%;
    border: 2px solid var(--c-white);
}


/* ── Page content ──────────────────────────────────────────── */
main {
    padding: 24px;
    flex: 1;
    background: var(--c-bg);
}


/* ── Cards / Panels ────────────────────────────────────────── */
/* Carpenter panel: white, 1px #e5e7eb border, 16px radius, minimal shadow */
.portu-card {
    background: var(--c-white);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-card);
    padding: 22px 24px;
    box-shadow: var(--shadow-card);
}

.portu-card-sm {
    padding: 16px 20px;
}

/* Stat card */
.stat-card {
    background: var(--c-white);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-card);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-card);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: 1px solid var(--c-border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--c-text-500);
}

.stat-icon svg { width: 22px; height: 22px; }
.stat-icon-filled { border: none; }
.stat-icon-1 { background: var(--c-blue-bg); color: var(--c-blue); border: none; }
.stat-icon-2 { background: #f0fdf4; color: var(--c-green-dark); border: none; }
.stat-icon-3 { background: #fffbeb; color: var(--c-amber-dark); border: none; }
.stat-icon-4 { background: #fef2f2; color: var(--c-red); border: none; }

.stat-label {
    font-size: 14px;
    font-weight: 400;
    color: var(--c-text-500);
    line-height: 1;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--c-text-900);
    line-height: 1.1;
    margin-top: 4px;
}


/* ── Table ─────────────────────────────────────────────────── */
.portu-table {
    width: 100%;
    border-collapse: collapse;
}

/* Column headers — 10px uppercase #6b7280 */
.portu-table thead th {
    font-weight: 400;
    font-size: 10px;
    color: var(--c-text-500);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 10px 16px;
    text-align: left;
    border-bottom: 1px solid var(--c-border);
}

/* Rows — 12px #1f2937 */
.portu-table tbody td {
    padding: 10px 16px;
    font-size: 12px;
    color: var(--c-text-800);
    border-bottom: 1px solid var(--c-border-light);
    vertical-align: middle;
}

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

.portu-table tbody tr:hover {
    background: var(--c-bg);
}


/* ── Badges ────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

.badge-success        { background: #f0fdf4; color: var(--c-green-dark); border: 1px solid #bbf7d0; }
.badge-danger,
.badge-error          { background: #fef2f2; color: var(--c-red);        border: 1px solid #fecaca; }
.badge-warning        { background: #fffbeb; color: var(--c-amber-dark); border: 1px solid #fde68a; }
.badge-success-soft   { background: #f0fdf4; color: var(--c-green-dark); }
.badge-danger-soft    { background: #fef2f2; color: var(--c-red); }
.badge-warning-soft   { background: #fffbeb; color: var(--c-amber-dark); }
.badge-neutral        { background: var(--c-bg); color: var(--c-text-500); }
.badge-system         { background: var(--c-bg); color: var(--c-text-700); border: 1px solid var(--c-border); }
.badge-info           { background: var(--c-blue-bg); color: var(--c-blue-active); }


/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 500;
    font-size: 14px;
    line-height: 1;
    border-radius: var(--radius-btn);
    padding: 9px 16px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary        { background: var(--c-blue);  color: white; }
.btn-primary:hover  { background: var(--c-blue-hover); color: white; }

.btn-ghost          { background: var(--c-bg); color: var(--c-text-700); border-color: var(--c-border); }
.btn-ghost:hover    { background: var(--c-border); color: var(--c-text-800); }

.btn-outlined       { background: transparent; color: var(--c-text-700); border-color: var(--c-border-input); }
.btn-outlined:hover { background: var(--c-bg); }

.btn-danger         { background: var(--c-red);      color: white; }
.btn-danger:hover   { background: var(--c-red-dark); color: white; }

.btn-success        { background: var(--c-green);      color: white; }
.btn-success:hover  { background: var(--c-green-dark); color: white; }

.btn-warning        { background: var(--c-amber);      color: white; }
.btn-warning:hover  { background: var(--c-amber-dark); color: white; }

.btn-sm   { padding: 6px 12px; font-size: 12px; border-radius: 6px; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: var(--radius-sm); }

.btn-cta-round {
    width: 36px; height: 36px; padding: 0;
    border-radius: var(--radius-sm);
    background: var(--c-blue); color: white;
    font-size: 20px; font-weight: 600;
    display: inline-flex; align-items: center; justify-content: center;
    border: none; cursor: pointer;
}


/* ── Form elements ─────────────────────────────────────────── */
.form-label {
    display: block;
    font-weight: 500;
    font-size: 14px;
    color: var(--c-text-800);
    margin-bottom: 6px;
}

/* Inputs — white, 1px border #d1d5db, 8px radius, 40px tall */
.form-input,
.form-select,
.form-textarea {
    width: 100%;
    background: var(--c-white);
    border: 1px solid var(--c-border-input);
    border-radius: var(--radius-sm);
    padding: 0 12px;
    height: 40px;
    font-size: 14px;
    font-weight: 400;
    font-family: 'Funnel Sans', sans-serif;
    color: var(--c-text-800);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    -webkit-appearance: none;
    appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--c-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--c-text-400);
}

.form-input[readonly],
.form-input[disabled] {
    background: var(--c-bg);
    color: var(--c-text-500);
    cursor: not-allowed;
}

.password-field {
    position: relative;
}

.password-field .form-input {
    padding-right: 44px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--c-text-500);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.password-toggle:hover {
    color: var(--c-text-700);
}

.password-toggle:focus-visible {
    outline: 2px solid var(--c-blue);
    outline-offset: 2px;
    border-radius: 6px;
}

.password-toggle svg {
    width: 18px;
    height: 18px;
}

.form-textarea {
    height: auto;
    min-height: 80px;
    padding: 10px 12px;
    resize: vertical;
    line-height: 1.5;
}

/* Select with chevron */
.form-select {
    background-image: url("data:image/svg+xml,%3Csvg width='14' height='9' viewBox='0 0 14 9' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L7 7.5L13 1.5' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

.form-checkbox {
    accent-color: var(--c-blue);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.form-hint {
    font-size: 12px;
    color: var(--c-text-500);
    margin-top: 4px;
    line-height: 1.4;
}


/* ── Pagination ────────────────────────────────────────────── */
.pagination-active {
    width: 36px; height: 36px;
    background: var(--c-blue); color: white;
    border-radius: var(--radius-sm);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 14px;
}

.pagination-inactive {
    width: 36px; height: 36px;
    border: 1px solid var(--c-border-input); color: var(--c-text-700);
    border-radius: var(--radius-sm);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 14px;
}


/* ── Dropdown component ────────────────────────────────────── */
/*
 * Usage:
 *   <div class="pd-root" data-pd>
 *     <button class="pd-toggle" data-pd-toggle>...</button>
 *     <div class="pd-menu" data-pd-menu>
 *       <a class="pd-item" href="...">...</a>
 *       <button class="pd-item" type="button">...</button>
 *       <hr class="pd-divider">
 *     </div>
 *   </div>
 *
 * The JS in base.html manages [data-pd-open] on the root element.
 * Placement modifiers: add class pd-menu-right, pd-menu-up to pd-menu.
 */

/* Root — establishes positioning context */
.pd-root {
    position: relative;
    display: inline-block;
}

/* When pd-root is also a topbar-icon-btn, preserve the icon-btn layout */
.topbar-icon-btn.pd-root {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Toggle button — intentionally unstyled; pair with .btn or custom classes */
.pd-toggle {
    cursor: pointer;
    user-select: none;
}

/* Menu panel */
.pd-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 200;
    min-width: 200px;
    background: var(--c-white);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 10px 24px -4px rgba(0,0,0,0.09);
    padding: 4px 0;
    /* Hidden state */
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    transform-origin: top left;
}

/* Right-aligned variant */
.pd-menu.pd-menu-right {
    left: auto;
    right: 0;
    transform-origin: top right;
}

/* Upward variant (opens above toggle) */
.pd-menu.pd-menu-up {
    top: auto;
    bottom: calc(100% + 6px);
    transform: translateY(6px) scale(0.98);
    transform-origin: bottom left;
}

.pd-menu.pd-menu-up.pd-menu-right {
    transform-origin: bottom right;
}

/* Open state — toggled by JS via [data-pd-open] on the root */
.pd-root[data-pd-open] .pd-menu {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Menu items */
.pd-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 400;
    color: var(--c-text-700);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: none;
    text-align: left;
    white-space: nowrap;
    transition: background 0.1s ease, color 0.1s ease;
    line-height: 1.4;
    font-family: 'Funnel Sans', sans-serif;
}

.pd-item:hover {
    background: var(--c-bg);
    color: var(--c-text-800);
}

.pd-item:focus-visible {
    outline: 2px solid var(--c-blue);
    outline-offset: -2px;
    background: var(--c-bg);
}

/* Danger variant */
.pd-item-danger {
    color: var(--c-red);
}

.pd-item-danger:hover {
    background: #fef2f2;
    color: var(--c-red-dark);
}

/* Item icon */
.pd-item svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    color: var(--c-text-400);
}

.pd-item:hover svg,
.pd-item:focus-visible svg {
    color: var(--c-text-600);
}

.pd-item-danger svg,
.pd-item-danger:hover svg {
    color: var(--c-red);
}

/* Divider */
.pd-divider {
    border: none;
    border-top: 1px solid var(--c-border-light);
    margin: 4px 0;
}

/* Section header inside menu */
.pd-section-header {
    padding: 8px 14px 4px;
    font-size: 10px;
    font-weight: 600;
    color: var(--c-text-400);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    line-height: 1;
}

/* ── Notification bell trigger wrapper ─────────────────────── */
/*
 * The notification bell uses a different pattern (HTMX-loaded content
 * injected into #notification-dropdown). We keep it as a positioned
 * container and animate the panel with the same portu-dropdown class.
 */

/* Legacy .portu-dropdown — kept for tenant switcher + notification panel */
.portu-dropdown {
    background: var(--c-white);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 10px 24px -4px rgba(0,0,0,0.09);
    overflow: hidden;
    /* Entry animation used when HTMX injects this panel */
    animation: pd-panel-enter 0.15s ease forwards;
}

@keyframes pd-panel-enter {
    from {
        opacity: 0;
        transform: translateY(-6px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.portu-dropdown button:hover,
.portu-dropdown a:hover {
    background: var(--c-bg);
}


/* ── Tabs ──────────────────────────────────────────────────── */
.portu-tab {
    font-weight: 500;
    font-size: 14px;
    color: var(--c-text-500);
    padding: 10px 16px;
    border-bottom: 2px solid transparent;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
    display: inline-block;
}

.portu-tab:hover { color: var(--c-text-800); }

.portu-tab.active {
    color: var(--c-text-800);
    font-weight: 600;
    border-bottom-color: var(--c-blue);
}


/* ── Alerts ────────────────────────────────────────────────── */
.alert-error {
    background: #fef2f2; border: 1px solid #fecaca;
    border-radius: var(--radius-sm); padding: 12px 16px;
    color: var(--c-red); font-size: 14px; line-height: 1.5;
}

.alert-success {
    background: #f0fdf4; border: 1px solid #bbf7d0;
    border-radius: var(--radius-sm); padding: 12px 16px;
    color: var(--c-green-dark); font-size: 14px; line-height: 1.5;
}

.alert-info {
    background: var(--c-blue-bg); border: 1px solid var(--c-blue-border);
    border-radius: var(--radius-sm); padding: 12px 16px;
    color: var(--c-blue-active); font-size: 14px; line-height: 1.5;
}

.alert-warning {
    background: #fffbeb; border: 1px solid #fde68a;
    border-radius: var(--radius-sm); padding: 12px 16px;
    color: var(--c-amber-dark); font-size: 14px; line-height: 1.5;
}


/* ── Log viewer ────────────────────────────────────────────── */
.log-viewer {
    background: #0f172a;
    border-radius: var(--radius-xs);
    padding: 16px 20px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    line-height: 1.6;
    color: #4ade80;
    max-height: 600px;
    overflow-y: auto;
}

.log-line {
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    line-height: 1.5;
}


/* ── Auth pages ────────────────────────────────────────────── */
.auth-page {
    min-height: 100vh;
    background: var(--c-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
}

/* Auth card — white, 1px border, 16px radius */
.auth-card {
    background: var(--c-white);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-card);
    padding: 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-card);
}

/* "Odoo." logo */
.auth-logo {
    font-weight: 600;
    font-size: 24px;
    line-height: 1;
    color: var(--c-text-800);
    text-align: center;
    margin-bottom: 8px;
    letter-spacing: -0.8px;
}

.auth-logo .dot { color: var(--c-blue); }

/* OAuth social buttons */
.oauth-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 10px 16px;
    border: 1px solid var(--c-border-input);
    border-radius: var(--radius-sm);
    font-weight: 500; font-size: 14px;
    color: var(--c-text-700); background: var(--c-white);
    cursor: pointer; transition: all 0.15s ease; text-decoration: none;
}

.oauth-btn:hover { background: var(--c-bg); border-color: var(--c-border); color: var(--c-text-800); }


/* ── Dividers ──────────────────────────────────────────────── */
.portu-divider {
    border: none;
    border-top: 1px solid var(--c-border);
    margin: 0;
}


/* ── Tenant switcher (sidebar) ─────────────────────────────── */
.tenant-switcher {
    padding: 10px 12px;
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    width: 100%; text-align: left;
    transition: background 0.15s ease;
}

.tenant-switcher:hover { background: var(--c-border-light); }


/* ── Selection cards (instance creation) ───────────────────── */
.selection-card {
    border: 1px solid var(--c-border);
    border-radius: var(--radius-card);
    padding: 20px;
    transition: all 0.15s ease;
    cursor: pointer;
}

.selection-card:hover { border-color: var(--c-blue-border); }

input[type="radio"]:checked ~ .selection-card,
input[type="radio"]:checked + .selection-card {
    border-color: var(--c-blue);
    background: var(--c-blue-bg);
}


/* ── Permission group card ─────────────────────────────────── */
.perm-group {
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    padding: 16px;
}


/* ── Detail grid ───────────────────────────────────────────── */
.detail-grid dt {
    font-size: 12px;
    font-weight: 400;
    color: var(--c-text-500);
}

.detail-grid dd {
    font-size: 14px;
    font-weight: 600;
    color: var(--c-text-800);
    margin-top: 2px;
}


/* ── Custom Select (cselect) ───────────────────────────────── */
/* Replaces native <select> with a styled JS-driven dropdown.  */
/* The native <select> stays hidden in the DOM for form submit. */

.cselect-wrapper {
    position: relative;
    width: 100%;
    display: block;
}

.cselect-trigger {
    width: 100%;
    background: var(--c-white);
    border: 1px solid var(--c-border-input);
    border-radius: var(--radius-sm);
    padding: 0 36px 0 12px;
    height: 40px;
    font-size: 14px;
    font-weight: 400;
    font-family: 'Funnel Sans', sans-serif;
    color: var(--c-text-800);
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    background-image: url("data:image/svg+xml,%3Csvg width='14' height='9' viewBox='0 0 14 9' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L7 7.5L13 1.5' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
}

.cselect-trigger:focus {
    outline: none;
    border-color: var(--c-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.cselect-wrapper[data-open] .cselect-trigger {
    border-color: var(--c-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.cselect-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.cselect-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--c-white);
    border: 1px solid var(--c-border-input);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.06);
    z-index: 300;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 0.12s ease, transform 0.12s ease;
    max-height: 240px;
    overflow-y: auto;
    min-width: 100%;
}

.cselect-wrapper[data-open] .cselect-menu {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

.cselect-option {
    padding: 9px 12px;
    font-size: 14px;
    font-family: 'Funnel Sans', sans-serif;
    cursor: pointer;
    color: var(--c-text-800);
    transition: background 0.1s;
    white-space: nowrap;
}

.cselect-option:hover,
.cselect-option[data-focused] {
    background: var(--c-bg);
}

.cselect-option[data-selected] {
    color: var(--c-blue);
    font-weight: 500;
    background: var(--c-blue-bg);
}


/* ── Tooltip ───────────────────────────────────────────────── */
.portu-tooltip {
    background: var(--c-text-800);
    border-radius: var(--radius-xs);
    padding: 8px 12px;
    color: white;
    font-size: 12px;
    font-weight: 400;
    position: relative;
    display: inline-block;
}

.portu-tooltip::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%) scaleY(-1);
    width: 14px;
    height: 8px;
    background: var(--c-text-800);
    clip-path: polygon(50% 100%, 0% 0%, 100% 0%);
}


/* ── Status animations ─────────────────────────────────────── */
@keyframes status-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.45; }
}

.status-provisioning {
    animation: status-pulse 2s ease-in-out infinite;
}


/* ── Metric placeholder ────────────────────────────────────── */
.metric-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 128px;
    color: var(--c-text-500);
    font-size: 14px;
}


/* ── Toggle switch ─────────────────────────────────────────── */
.portu-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    cursor: pointer;
}

.portu-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.portu-toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--c-border-input);
    border-radius: 12px;
    transition: background 0.15s ease;
}

.portu-toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.15s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.portu-toggle input:checked ~ .portu-toggle-slider {
    background: var(--c-blue);
}

.portu-toggle input:checked ~ .portu-toggle-slider::before {
    transform: translateX(20px);
}


/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1200px) {
    :root { --sidebar-width: 220px; }
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
}

@media (max-width: 640px) {
    .search-bar { display: none; }
    .auth-card  { padding: 32px 20px; }
}

/* ── Resource Sliders (instance create form) ───────────────── */
.resource-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 5px;
    border-radius: 3px;
    background: #e5e7eb;
    outline: none;
    cursor: pointer;
    margin-top: 8px;
    display: block;
}
.resource-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(59,130,246,0.4);
    transition: transform 0.1s;
}
.resource-slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
.resource-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    border: none;
    box-shadow: 0 1px 4px rgba(59,130,246,0.4);
}
.resource-slider:focus::-webkit-slider-thumb { box-shadow: 0 0 0 3px rgba(59,130,246,0.2); }
