/* =========================================================================
   Aqua Scope Backend v2 — /d/ portal
   Layout: Sidebar (left) + Topbar (top) + Content
   Mobile: off-canvas sidebar via hamburger
   Backwards-compatible with the class catalog of /c/css/style.css so that
   existing apps continue to render correctly.
   ========================================================================= */

/* ---------- Design tokens ---------- */
:root {
    --primary:        #0077b6;
    --primary-dark:   #005f8a;
    --primary-light:  #90cdf4;
    --primary-ghost:  #ebf8ff;

    --sidebar-bg:     #0f1e2d;
    --sidebar-fg:     #cbd5e0;
    --sidebar-muted:  #7a8ea3;
    --sidebar-active: #ffffff;
    --sidebar-hover:  #1a3149;

    --topbar-bg:      #ffffff;
    --topbar-border:  #e2e8f0;

    --page-bg:        #f0f4f8;
    --card-bg:        #ffffff;
    --text:           #1a202c;
    --text-muted:     #4a5568;
    --text-faded:     #718096;
    --border:         #e2e8f0;

    --success:        #38a169;
    --warning:        #dd6b20;
    --danger:         #e53e3e;

    --radius:         8px;
    --radius-sm:      4px;
    --shadow-sm:      0 1px 6px rgba(0, 0, 0, 0.08);
    --shadow-md:      0 4px 16px rgba(0, 0, 0, 0.12);

    --sidebar-w:      260px;
    --topbar-h:       56px;

    --font-sans:      -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-sans);
    background: var(--page-bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.4;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

button { font-family: inherit; }

/* =========================================================================
   Login page
   ========================================================================= */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f1e2d 0%, #163454 60%, #0077b6 100%);
    padding: 1rem;
}

.login-container {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 400px;
}
.login-container h1 { font-size: 1.7rem; color: var(--primary); margin-bottom: 0.25rem; }
.login-container .subtitle { color: var(--text-faded); margin-bottom: 1.5rem; font-size: 0.9rem; }
.login-container label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.3rem; color: var(--text-muted); }
.login-container input {
    width: 100%; padding: 0.65rem 0.75rem;
    border: 1px solid #cbd5e0; border-radius: var(--radius-sm);
    font-size: 0.95rem; margin-bottom: 1rem;
    font-family: inherit;
}
.login-container input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 119, 182, 0.2);
}
.login-container .remember-label {
    display: flex; align-items: center; gap: 0.4rem;
    font-weight: 400; margin-bottom: 1rem; cursor: pointer;
}
.login-container .remember-label input[type="checkbox"] { width: auto; margin-bottom: 0; }
.login-container button {
    width: 100%; padding: 0.75rem;
    background: var(--primary); color: #fff;
    border: none; border-radius: var(--radius-sm);
    font-size: 1rem; font-weight: 600; cursor: pointer;
    transition: background 0.15s;
}
.login-container button:hover { background: var(--primary-dark); }

.error {
    background: #fff5f5; color: #c53030;
    border: 1px solid #feb2b2;
    padding: 0.6rem 0.75rem; border-radius: var(--radius-sm);
    margin-bottom: 1rem; font-size: 0.9rem;
}

.success {
    background: #f0fff4; color: #276749;
    border: 1px solid #9ae6b4;
    padding: 0.6rem 0.75rem; border-radius: var(--radius-sm);
    margin-bottom: 1rem; font-size: 0.9rem;
}

/* =========================================================================
   App shell — Sidebar + Topbar + Main
   ========================================================================= */

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar (always off-canvas overlay) ---------- */

.sidebar {
    width: min(300px, 88vw);
    background: var(--sidebar-bg);
    color: var(--sidebar-fg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.3);
}
body.sidebar-open .sidebar { transform: translateX(0); }

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand-link {
    display: flex; align-items: center; gap: 0.6rem;
    color: #fff; font-weight: 700; font-size: 1.05rem;
    text-decoration: none;
}
.sidebar-brand-link:hover { color: #fff; }

.sidebar-brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 6px;
    background: var(--primary); color: #fff;
    font-weight: 700; font-size: 1rem;
}

.sidebar-close {
    display: block;
    background: transparent; color: #fff; border: none;
    font-size: 1.6rem; line-height: 1; cursor: pointer;
    padding: 0.2rem 0.5rem;
}

.sidebar-nav {
    flex: 1;
    padding: 0.5rem 0 1rem;
}

.sidebar-group {
    border: none;
}

.sidebar-group[open] .sidebar-group-caret { transform: rotate(90deg); }

.sidebar-group-head {
    list-style: none;
    display: flex; align-items: center; gap: 0.55rem;
    padding: 0.55rem 1rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--sidebar-muted);
    cursor: pointer;
    user-select: none;
}
.sidebar-group-head::-webkit-details-marker { display: none; }
.sidebar-group-head:hover { color: #fff; }

.sidebar-group-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 4px;
    background: rgba(255,255,255,0.06);
    color: var(--sidebar-fg);
    font-size: 0.75rem; font-weight: 700;
}

.sidebar-group-label { flex: 1; }

.sidebar-group-caret {
    color: var(--sidebar-muted);
    font-size: 1rem;
    transition: transform 0.15s;
}

.sidebar-group-items {
    list-style: none;
    padding: 0.1rem 0 0.4rem;
}

.sidebar-link {
    display: block;
    padding: 0.5rem 1rem 0.5rem 3rem;
    color: var(--sidebar-fg);
    text-decoration: none;
    font-size: 0.9rem;
    border-left: 3px solid transparent;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
    border-left-color: var(--primary-light);
}
.sidebar-link.active {
    background: var(--sidebar-hover);
    color: var(--sidebar-active);
    border-left-color: var(--primary);
    font-weight: 600;
}
.sidebar-link-placeholder {
    color: var(--sidebar-muted);
    cursor: not-allowed;
    font-style: italic;
    opacity: 0.65;
}

.sidebar-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 0.8rem;
    color: var(--sidebar-muted);
}
.sidebar-user::before { content: "· "; opacity: 0.5; }

/* ---------- Sidebar backdrop (mobile) ---------- */

.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15, 30, 45, 0.5);
    z-index: 30;
}
body.sidebar-open .sidebar-backdrop { display: block; }

/* ---------- Main content column ---------- */

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--page-bg);
}

/* ---------- Topbar ---------- */

.topbar {
    height: var(--topbar-h);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 0.75rem;
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.hamburger {
    display: block;
    background: transparent; border: none;
    width: 40px; height: 40px;
    padding: 8px;
    cursor: pointer;
    flex-shrink: 0;
}
.hamburger:hover { background: #f7fafc; border-radius: 4px; }
.hamburger span {
    display: block; width: 100%; height: 2px;
    background: var(--text); margin: 5px 0;
    border-radius: 1px;
}

.topbar-title {
    display: flex; align-items: baseline; gap: 0.4rem;
    flex: 1; min-width: 0;
    overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.topbar-brand {
    font-weight: 700; color: var(--primary);
    font-size: 1rem;
    text-decoration: none;
}
.topbar-brand:hover { color: var(--primary-dark); }
.topbar-sep { color: #a0aec0; font-size: 0.9rem; }
.topbar-app {
    color: var(--text);
    font-weight: 600;
    font-size: 1rem;
    overflow: hidden; text-overflow: ellipsis;
}

.topbar-user {
    display: flex; align-items: center; gap: 1rem;
    font-size: 0.85rem;
    color: var(--text-faded);
}
.topbar-user-name strong { color: var(--text); font-weight: 600; }
.topbar-logout {
    color: var(--danger);
    text-decoration: none;
    font-weight: 600;
}
.topbar-logout:hover { text-decoration: underline; color: var(--danger); }

/* ---------- Main content wrapper (kept as .dashboard for BC) ---------- */

.dashboard {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 2.5rem;
    width: 100%;
}

.dashboard h1 { font-size: 1.5rem; color: var(--text); margin-bottom: 0.75rem; }
.dashboard h2 { font-size: 1.15rem; color: var(--text); margin: 1.25rem 0 0.5rem; }

/* Legacy .site-header markup (from /c/) — hide if any app still emits it manually */
.dashboard .site-header {
    display: none;
}

/* ---------- App-level tabs (public contract for apps) ---------- */

.app-nav {
    display: flex; gap: 0;
    margin: -0.25rem 0 1.5rem;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.app-nav-link {
    display: inline-block;
    padding: 0.6rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
}
.app-nav-link:hover { color: var(--primary); border-bottom-color: var(--primary-light); }
.app-nav-link.active { color: var(--primary); font-weight: 600; border-bottom-color: var(--primary); }

.app-nav-spacer { margin-bottom: 1rem; }

/* =========================================================================
   Welcome page (index.php)
   ========================================================================= */

.welcome h1 { font-size: 1.7rem; color: var(--primary); margin-bottom: 0.35rem; }
.welcome-lead { color: var(--text-faded); margin-bottom: 2rem; max-width: 60ch; }

.welcome-groups {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}
.welcome-group {
    background: var(--card-bg);
    padding: 1.1rem 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.welcome-group h2 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--primary);
    margin: 0 0 0.6rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border);
}
.welcome-group ul { list-style: none; }
.welcome-group li { margin: 0.15rem 0; }
.welcome-group a {
    display: block;
    padding: 0.35rem 0;
    color: var(--text);
    font-size: 0.92rem;
    border-radius: 3px;
}
.welcome-group a:hover { color: var(--primary); }

/* =========================================================================
   Backwards-compatible class catalog (from /c/css/style.css)
   Same class names, refreshed with tokens where useful. Apps that use these
   classes render correctly under the new shell.
   ========================================================================= */

/* ---- App grid & cards (legacy dashboard) ---- */
.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}
.app-card {
    display: block;
    background: var(--card-bg);
    padding: 1.4rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.15s, transform 0.15s;
}
.app-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.app-card h2 { font-size: 1.05rem; color: var(--primary); margin-bottom: 0.4rem; }
.app-card p { font-size: 0.85rem; color: var(--text-faded); }

/* ---- Legacy brand-link + site-brand (in case any app renders them) ---- */
.site-brand { display: flex; align-items: center; gap: 0.4rem; }
.brand-link { font-size: 1.05rem; font-weight: 700; color: var(--primary); text-decoration: none; }
.brand-link:hover { color: var(--primary-dark); }
.brand-sep { color: #a0aec0; font-size: 1rem; }
.brand-app { font-size: 1.05rem; font-weight: 600; color: var(--text); }
.site-user { display: flex; align-items: center; gap: 1rem; font-size: 0.85rem; color: var(--text-faded); }
.site-user a { color: var(--primary); text-decoration: none; font-weight: 600; }
.site-user a:hover { text-decoration: underline; }
.site-logout { color: var(--danger) !important; }

/* ---- Admin panel ---- */
.section-title { font-size: 1.1rem; color: var(--text); margin: 1.5rem 0 0.75rem; }

.user-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}
.user-table th, .user-table td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
}
.user-table th { background: #f7fafc; font-weight: 600; color: var(--text-muted); }
.user-table td.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

.inline-form { display: flex; gap: 0.35rem; align-items: center; }
.inline-form input[type="password"], .inline-form input[type="text"] {
    padding: 0.3rem 0.5rem;
    border: 1px solid #cbd5e0;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    width: 130px;
    font-family: inherit;
}

/* ---- Buttons ---- */
.btn { border: none; cursor: pointer; border-radius: var(--radius-sm); font-weight: 600; font-family: inherit; }

.btn-small { padding: 0.35rem 0.7rem; font-size: 0.8rem; background: var(--primary); color: #fff; }
.btn-small:hover { background: var(--primary-dark); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c53030; }

.btn-useful { background: var(--success); color: #fff; }
.btn-useful:hover { background: #2f855a; }

.btn-warning {
    background: var(--warning); color: #fff;
    text-decoration: none; display: inline-block;
    padding: 0.35rem 0.7rem; font-size: 0.8rem;
    border-radius: var(--radius-sm); font-weight: 600;
}
.btn-warning:hover { background: #c05621; }

.btn-fetch {
    padding: 0.6rem 1.2rem;
    background: var(--primary); color: #fff;
    border: none; border-radius: var(--radius-sm);
    font-size: 0.9rem; font-weight: 600; cursor: pointer;
    font-family: inherit;
}
.btn-fetch:hover { background: var(--primary-dark); }

/* ---- Admin form ---- */
.admin-form {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    max-width: 480px;
}
.admin-form label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.3rem; color: var(--text-muted); }
.admin-form input[type="text"],
.admin-form input[type="password"],
.admin-form input[type="email"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #cbd5e0;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    margin-bottom: 1rem;
    font-family: inherit;
}
.admin-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(0, 119, 182, 0.2);
}
.admin-form button {
    padding: 0.7rem 1.5rem;
    background: var(--primary); color: #fff;
    border: none; border-radius: var(--radius-sm);
    font-size: 1rem; font-weight: 600; cursor: pointer;
    font-family: inherit;
}
.admin-form button:hover { background: var(--primary-dark); }

.checkbox-label {
    display: flex !important; align-items: center; gap: 0.5rem;
    font-weight: normal !important; margin-bottom: 1rem;
}
.checkbox-label input[type="checkbox"] { width: auto; margin: 0; }
.checkbox-group { margin-bottom: 1rem; }
.checkbox-group .checkbox-label { margin-bottom: 0.4rem; }

/* ---- Discovery / Results ---- */
.discovery-actions { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.result-count { font-size: 0.85rem; color: var(--text-faded); }
.result-card {
    display: flex; justify-content: space-between; align-items: flex-start;
    background: var(--card-bg);
    padding: 1.1rem 1.4rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 0.75rem;
    border-left: 4px solid transparent;
    transition: border-color 0.15s;
    gap: 1rem;
}
.result-card:hover { border-left-color: var(--primary); }
.result-content { flex: 1; min-width: 0; }
.result-content h3 { font-size: 1rem; margin: 0.3rem 0; }
.result-content h3 a { color: var(--text); text-decoration: none; }
.result-content h3 a:hover { color: var(--primary); }
.snippet { font-size: 0.85rem; color: var(--text-faded); margin: 0; }
.keyword-badge {
    display: inline-block; background: var(--primary-ghost);
    color: var(--primary); font-size: 0.75rem; font-weight: 600;
    padding: 0.15rem 0.5rem; border-radius: 3px;
}
.domain-label { font-size: 0.75rem; color: #a0aec0; margin-left: 0.5rem; }
.date-label { font-size: 0.75rem; color: #a0aec0; }
.result-actions { margin-left: 1rem; flex-shrink: 0; }
.result-actions form { display: flex; gap: 0.35rem; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-faded); }
.empty-state h3 { color: var(--text-muted); margin-bottom: 0.5rem; }
.empty-state a { color: var(--primary); }

/* ---- Filter bar ---- */
.filter-bar { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filter-chip {
    display: inline-block;
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem; border-radius: 20px;
    background: #edf2f7; color: var(--text-muted);
    text-decoration: none; font-weight: 600;
}
.filter-chip:hover { background: #e2e8f0; }
.filter-chip.active { background: var(--primary); color: #fff; }

/* ---- SEO Keyword ranks / badges ---- */
.engine-badge {
    display: inline-block;
    background: #f7fafc; border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.2rem 0.5rem; font-size: 0.8rem; margin: 0.15rem;
}
.rank-badge { font-size: 0.75rem; padding: 0.1rem 0.4rem; border-radius: 3px; margin-left: 0.25rem; }
.rank-good { background: #d4edda; color: #155724; }
.rank-mid  { background: #fff3cd; color: #856404; }
.rank-none { background: #f8d7da; color: #721c24; }

.status-badge {
    display: inline-block; padding: 0.15rem 0.5rem;
    border-radius: 3px; font-size: 0.8rem; font-weight: 600;
}
.status-active   { background: #d4edda; color: #155724; }
.status-inactive { background: #e2e8f0; color: var(--text-faded); }

.edit-mode { display: none; }

td:has(.engine-badge) { white-space: nowrap; }
td:has(.btn-small)    { white-space: nowrap; }

/* ---- Invoices ---- */
.invoice-group { margin-bottom: 0.75rem; }
.invoice-group > summary {
    font-size: 1.1rem; font-weight: 600; color: var(--text);
    cursor: pointer; padding: 0.75rem 1rem;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    list-style: none;
    display: flex; align-items: center; gap: 0.75rem;
}
.invoice-group > summary::-webkit-details-marker { display: none; }
.invoice-group > summary::before {
    content: "\25B6"; font-size: 0.7rem;
    color: var(--primary); transition: transform 0.15s;
}
.invoice-group[open] > summary::before { transform: rotate(90deg); }
.invoice-group > summary:hover { background: #f7fafc; }
.invoice-group-meta { font-size: 0.85rem; font-weight: 400; color: var(--text-faded); }

.invoice-year > summary { font-size: 1.2rem; background: var(--primary-ghost); }
.invoice-year > summary:hover { background: #d6eef8; }
.invoice-subgroup { margin-left: 1rem; }
.invoice-subgroup > summary { font-size: 1rem; }
.invoice-table { margin-top: 0.5rem; margin-bottom: 0.5rem; }
.invoice-table .text-right { text-align: right; }
.invoice-items { font-size: 0.8rem; color: var(--text-faded); }

/* ---- Stock ---- */
.stock-critical { background: #fff5f5; color: #c53030; font-weight: 600; }
.sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
.sort-link:hover { color: var(--primary); }

/* ---- CRM ---- */
.crm-due-overdue { background: #fff5f5; }
.crm-due-soon    { background: #fffff0; }
.crm-due-ok      { background: #f0fff4; }
.crm-due-later   { background: transparent; }

.stage-badge {
    display: inline-block; padding: 0.15rem 0.5rem;
    border-radius: 3px; font-size: 0.75rem; font-weight: 600;
    white-space: nowrap;
}

.crm-info-card {
    background: var(--card-bg);
    padding: 1.4rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}
.crm-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}
.crm-info-item { font-size: 0.85rem; color: var(--text-muted); }
.crm-info-item strong {
    display: block; font-size: 0.75rem; color: #a0aec0;
    text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 0.2rem;
}
.crm-info-item a { color: var(--primary); text-decoration: none; }
.crm-info-item a:hover { text-decoration: underline; }

.crm-notes {
    margin-top: 1rem; padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.85rem; color: var(--text-muted);
}
.crm-notes strong {
    display: block; font-size: 0.75rem; color: #a0aec0;
    text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 0.3rem;
}
.crm-edit-form label {
    display: block; font-size: 0.8rem; font-weight: 600;
    color: var(--text-muted); margin-bottom: 0.2rem;
}
.crm-edit-form input[type="text"],
.crm-edit-form input[type="email"],
.crm-edit-form input[type="date"],
.crm-edit-form select {
    width: 100%; padding: 0.5rem 0.6rem;
    border: 1px solid #cbd5e0; border-radius: var(--radius-sm);
    font-size: 0.9rem; font-family: inherit;
}
.crm-edit-form input:focus,
.crm-edit-form select:focus,
.crm-edit-form textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(0, 119, 182, 0.2);
}
.crm-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}
.crm-dialog {
    border: none; border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    padding: 1.5rem; max-width: 520px; width: 90vw;
}
.crm-dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
.crm-dialog h3 { font-size: 1.1rem; color: var(--primary); margin-bottom: 1rem; }
.crm-dialog label {
    display: block; font-size: 0.8rem; font-weight: 600;
    color: var(--text-muted); margin-bottom: 0.2rem;
}
.crm-dialog code {
    background: #f7fafc; padding: 0.1rem 0.3rem;
    border-radius: 3px; font-size: 0.8rem;
}
.crm-doc-list td a { color: var(--primary); text-decoration: none; font-weight: 600; }
.crm-doc-list td a:hover { text-decoration: underline; }
.crm-action-form > summary::-webkit-details-marker { display: none; }
.crm-action-form > summary { list-style: none; }

/* =========================================================================
   Responsive — Mobile (< 900px)
   ========================================================================= */

@media (max-width: 899px) {
    .topbar-user-name { display: none; }
    .topbar-app { font-size: 0.95rem; }
    .dashboard { padding: 1rem 0.9rem 2rem; }
    .welcome-groups { grid-template-columns: 1fr; }
    .app-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .topbar { padding: 0 0.5rem; }
    .topbar-brand { font-size: 0.95rem; }
    .topbar-sep { display: none; }
    .topbar-app { font-size: 0.9rem; }
}

/* Print: hide chrome */
@media print {
    .sidebar, .topbar, .sidebar-backdrop { display: none !important; }
    .dashboard { max-width: none; padding: 0; }
}
