html { color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }

:root {
    --sidebar-width: 260px;
    --topbar-height: 56px;
    --color-bg: #f1f5f9;
    --color-sidebar: #1e293b;
    --color-sidebar-text: #cbd5e1;
    --color-sidebar-active: #3b82f6;
    --color-text: #0f172a;
    --color-text-muted: #475569;
    --color-border: #cbd5e1;
    --color-card: #ffffff;
    --color-success: #16a34a;
    --color-warning: #d97706;
    --color-danger: #dc2626;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.12);
    --color-green-soft: #dcfce7;
    --color-red-soft: #fef2f2;
}

/* Accent: Blue (default) */
[data-accent="blue"], [data-accent=""] { --color-primary: #3b82f6; --color-primary-hover: #2563eb; --color-blue: #3b82f6; }
/* Accent: Orange */
[data-accent="orange"] { --color-primary: #f97316; --color-primary-hover: #ea580c; --color-blue: #f97316; }
/* Accent: Green */
[data-accent="green"] { --color-primary: #22c55e; --color-primary-hover: #16a34a; --color-blue: #22c55e; }
/* Accent: Purple */
[data-accent="purple"] { --color-primary: #a855f7; --color-primary-hover: #9333ea; --color-blue: #a855f7; }
/* Accent: Red */
[data-accent="red"] { --color-primary: #ef4444; --color-primary-hover: #dc2626; --color-blue: #ef4444; }

[data-theme="dark"] {
    --color-bg: #0f172a;
    --color-sidebar: #020617;
    --color-sidebar-text: #94a3b8;
    --color-text: #f1f5f9;
    --color-text-muted: #94a3b8;
    --color-border: #334155;
    --color-card: #1e293b;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.4);
    --color-green-soft: #064e3b;
    --color-red-soft: #450a0a;
}

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

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

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

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--color-sidebar);
    color: var(--color-sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar__logo { padding: 16px 20px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar__logo-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    text-decoration: none;
}

.sidebar__nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.sidebar__section { padding: 0 12px; margin-bottom: 16px; }
.sidebar__section-title { font-size: 14px; text-transform: uppercase; letter-spacing: 0.05em; color: #a5b4c7; padding: 4px 8px; margin-bottom: 4px; }

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    color: var(--color-sidebar-text);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(.4,0,.2,1);
}
.sidebar__link:hover { background: rgba(255,255,255,0.08); color: #fff; text-decoration: none; }
.sidebar__link--active { background: rgba(59,130,246,0.2); color: #60a5fa; box-shadow: 0 1px 4px rgba(59,130,246,0.15); }

.sidebar__footer { padding: 12px 20px; border-top: 1px solid rgba(255,255,255,0.08); font-size: 14px; }
.sidebar__version { color: #a5b4c7; display: block; }
.sidebar__version:hover { color: rgba(255,255,255,0.9); text-decoration: none; }
.sidebar__copyright { display: block; color: #a5b4c7; font-size: 14px; margin-top: 4px; }

/* Main */
.main { flex: 1; margin-left: var(--sidebar-width); display: flex; flex-direction: column; min-width: 0; }

/* Topbar */
.topbar {
    height: var(--topbar-height);
    background: var(--color-card);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar__title { font-size: 18px; font-weight: 600; }
.topbar__actions { display: flex; align-items: center; gap: 16px; }

/* Burger — mobile only (sidebar is fixed on desktop) */
.topbar__burger {
    display: none;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: var(--color-text);
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}
.topbar__burger:hover { background: var(--color-bg); }
.topbar__burger:active { transform: scale(0.94); }
.topbar__burger:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.topbar__search { display: flex; align-items: center; }
.topbar__search-input {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-size: 14px;
    width: 200px;
    outline: none;
}
.topbar__search-input:focus { border-color: var(--color-primary); }
.topbar__search-btn { background: none; border: none; cursor: pointer; color: var(--color-text-muted); padding: 6px; }

.topbar__user { display: flex; align-items: center; gap: 8px; font-size: 14px; }

/* Theme toggle */
.topbar__theme-group { display: flex; align-items: center; gap: 4px; position: relative; }
.topbar__theme-btn {
    background: none; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
    cursor: pointer; padding: 6px; line-height: 1; display: flex;
    color: var(--color-text-muted); transition: all 0.15s;
}
.topbar__theme-btn:hover { background: var(--color-bg); color: var(--color-text); }
[data-theme="light"] .theme-icon--dark { display: none; }
[data-theme="dark"] .theme-icon--light { display: none; }
.topbar__logout button { background: none; border: none; cursor: pointer; color: var(--color-text-muted); padding: 4px; }
.topbar__logout button:hover { color: var(--color-danger); }

/* Accent color picker */
.topbar__accent-btn {
    background: none; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
    cursor: pointer; padding: 6px; line-height: 1; display: flex; align-items: center; justify-content: center;
    color: var(--color-text-muted); transition: all 0.15s; width: 32px; height: 32px;
}
.topbar__accent-btn:hover { background: var(--color-bg); }
.accent-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--color-primary); display: block; flex-shrink: 0; }
.accent-menu {
    position: absolute; top: 100%; left: 0; margin-top: 8px;
    background: var(--color-card); border: 1px solid var(--color-border);
    border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 200;
    padding: 12px; display: none; min-width: 180px;
}
.accent-menu--open { display: block; }
.accent-menu__title { font-size: 14px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); margin-bottom: 8px; font-weight: 600; }
.accent-menu__grid { display: flex; gap: 8px; }
.accent-option {
    width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent;
    cursor: pointer; transition: all 0.15s; padding: 0;
}
.accent-option:hover { transform: scale(1.15); }
.accent-option--active { border-color: var(--color-text); box-shadow: 0 0 0 2px var(--color-card); }

/* Theme transition overlay */
.theme-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    z-index: 9999; pointer-events: none;
    background: var(--color-bg);
    animation: themeReveal 0.5s ease-in-out forwards;
}
@keyframes themeReveal {
    from { clip-path: circle(0% at var(--click-x, 50%) var(--click-y, 50%)); }
    to { clip-path: circle(150% at var(--click-x, 50%) var(--click-y, 50%)); }
}

/* Version link */
.version-link { color: var(--color-text-muted); text-decoration: none; }
.version-link:hover { color: var(--color-primary); text-decoration: underline; }

/* Auth logo */
.auth-logo { margin-bottom: 4px; display: flex; justify-content: center; }
.auth-logo svg { display: block; }

/* Content */
.content { padding: 24px; flex: 1; min-width: 0; }

/* Toast */
.toast {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
    animation: fadeIn 0.3s;
}
.toast--success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.toast--error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* Cards */
.card { background: var(--color-card); border: 1px solid var(--color-border); border-radius: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02); margin-bottom: 16px; }
.card__header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--color-border); }
.card__title { font-size: 15px; font-weight: 600; }
.card__body { padding: 16px 20px; }

/* Links in cards — always visible blue */
.card a:not(.btn):not(.kebab__item) { color: #3b82f6; text-decoration: none; transition: color 0.15s; }
.card a:not(.btn):not(.kebab__item):hover { color: #2563eb; text-decoration: underline; }

/* Links in dashboard content — visible blue */
.dashboard a:not(.btn):not(.kebab__item):not(.nav-link):not(.sidebar__link) { color: #3b82f6; text-decoration: none; transition: color 0.15s; }
.dashboard a:not(.btn):not(.kebab__item):not(.nav-link):not(.sidebar__link):hover { color: #2563eb; text-decoration: underline; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 20px; text-align: center; box-shadow: var(--shadow); }
.stat-card__value { font-size: 28px; font-weight: 700; color: var(--color-text); }
.stat-card__label { font-size: 14px; color: var(--color-text-muted); margin-top: 4px; }
.stat-card--green .stat-card__value { color: var(--color-success); }
.stat-card--blue .stat-card__value { color: var(--color-blue); }
.stat-card--yellow .stat-card__value { color: var(--color-warning); }
.stat-card--red .stat-card__value { color: var(--color-danger); }

/* Tables */
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th { text-align: left; font-size: 14px; font-weight: 700; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.06em; padding: 10px 12px; border-bottom: 2px solid var(--color-border); }
.table td { padding: 12px 12px; border-bottom: 1px solid var(--color-border); font-size: 14px; vertical-align: middle; }
.table--full { background: var(--color-card); border: 1px solid var(--color-border); border-radius: 14px; overflow: hidden; }
.table--full th { background: #f8fafc; }
.table--full tr:last-child td { border-bottom: none; }
.table--full tr:hover td { background: #f8fafc; }
.table--full td a { font-weight: 500; }

.row--overdue td { background: #fef2f2 !important; }

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    white-space: nowrap;
}
.badge--sm { padding: 1px 8px; font-size: 14px; }

/* Progress bar */
.progress-bar { position: relative; height: 20px; background: #e2e8f0; border-radius: 12px; overflow: hidden; min-width: 80px; }
.progress-bar--lg { height: 28px; }
.progress-bar__fill { height: 100%; background: linear-gradient(135deg, var(--color-primary), #818cf8); border-radius: 12px; transition: width 0.4s cubic-bezier(.4,0,.2,1); }
.progress-bar__text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 14px; font-weight: 600; color: var(--color-text); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    background: var(--color-card);
    color: var(--color-text);
    text-decoration: none;
    transition: all 0.2s cubic-bezier(.4,0,.2,1);
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.btn:hover { background: #f1f5f9; text-decoration: none; box-shadow: 0 2px 8px rgba(0,0,0,0.08); transform: translateY(-1px); }
.btn:active { transform: translateY(0); box-shadow: 0 1px 2px rgba(0,0,0,0.06); }
.btn--primary { background: var(--color-primary); color: #fff; box-shadow: 0 2px 8px rgba(59,130,246,0.25); }
.btn--primary:hover { background: var(--color-primary-hover); box-shadow: 0 4px 14px rgba(59,130,246,0.35); }
.btn--ghost { background: transparent; box-shadow: none; }
.btn--ghost:hover { background: #f1f5f9; box-shadow: none; transform: none; }
.btn--danger { background: var(--color-danger); color: #fff; box-shadow: 0 2px 8px rgba(239,68,68,0.25); }
.btn--danger:hover { background: #dc2626; box-shadow: 0 4px 14px rgba(239,68,68,0.35); }
.btn--sm { padding: 6px 14px; font-size: 14px; border-radius: 10px; }
.btn--xs { padding: 4px 10px; font-size: 14px; border-radius: 8px; }
.btn--full { width: 100%; justify-content: center; }
.btn--disabled, .btn[disabled] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.btn-icon { background: none; border: none; cursor: pointer; color: var(--color-text-muted); font-size: 14px; padding: 4px 8px; border-radius: 8px; transition: all 0.15s; }
.btn-icon:hover { color: var(--color-danger); background: var(--color-red-soft); }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label, .form-label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.3px; }
.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--color-border);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    background: var(--color-card);
    color: var(--color-text);
    outline: none;
    transition: all 0.2s cubic-bezier(.4,0,.2,1);
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.form-input:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.12); }
.form-input:hover { border-color: #cbd5e1; }
select.form-input { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
input[type="date"].form-input { cursor: pointer; }
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--color-border);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    background: var(--color-card);
    color: var(--color-text);
    outline: none;
    transition: all 0.2s cubic-bezier(.4,0,.2,1);
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.form-control:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.12); }
.form-control--sm { padding: 6px 10px; font-size: 14px; }
.form-control--lg { padding: 12px 16px; font-size: 16px; }
.form-control--color { width: 60px; height: 36px; padding: 2px; cursor: pointer; }
textarea.form-control { resize: vertical; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }
.form-actions { display: flex; gap: 12px; margin-top: 20px; }

/* Page header */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.page-header h2 { font-size: 22px; font-weight: 700; }
.page-header__actions { display: flex; gap: 8px; }
.page-header__badges { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.breadcrumb { display: inline-block; font-size: 14px; color: var(--color-text-muted); margin-bottom: 8px; }
.breadcrumb:hover { color: var(--color-primary); }

/* Direction rows */
.direction-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--color-border); text-decoration: none; color: var(--color-text); }
.direction-row:hover { background: #f8fafc; text-decoration: none; }
.direction-row__color { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.direction-row__name { flex: 1; font-weight: 500; }
.direction-row__count { font-size: 14px; color: var(--color-text-muted); }

/* Directions grid */
.directions-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.direction-card { background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.direction-card__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.direction-card__name { font-size: 16px; font-weight: 600; }
.direction-card__name a { color: var(--color-text); }
.direction-card__desc { font-size: 14px; color: var(--color-text-muted); margin-bottom: 12px; }
.direction-card__stats { display: flex; gap: 16px; font-size: 14px; color: var(--color-text-muted); margin-bottom: 12px; }
.direction-card__actions { display: flex; gap: 8px; }

/* Detail table */
.detail-table { width: 100%; }
.detail-table td { padding: 8px 0; border-bottom: 1px solid #f1f5f9; font-size: 14px; vertical-align: top; }
.detail-label { font-weight: 500; color: var(--color-text-muted); width: 200px; white-space: nowrap; }

/* Record meta */
.record-meta { margin-top: 14px; }
.record-meta__head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.record-meta__head svg { color: var(--color-text-muted); flex-shrink: 0; }
.record-meta__head-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--color-text-muted); }
.record-meta__body { background: var(--color-card); border: 1px solid var(--color-border); border-radius: 12px; overflow: hidden; }
.record-meta__row { display: flex; align-items: baseline; gap: 12px; padding: 10px 14px; }
.record-meta__row + .record-meta__row { border-top: 1px solid var(--color-border); }
.record-meta__key { display: flex; align-items: center; gap: 8px; min-width: 210px; flex-shrink: 0; font-size: 13px; font-weight: 500; color: var(--color-text-muted); }
.record-meta__key svg { flex-shrink: 0; opacity: 0.85; }
.record-meta__value { font-size: 14px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.record-meta__source { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; background: var(--color-bg); border: 1px solid var(--color-border); font-size: 13px; color: var(--color-text); }
@media (max-width: 640px) {
    .record-meta__row { flex-direction: column; align-items: flex-start; gap: 4px; }
    .record-meta__key { min-width: 0; }
}

/* Detail grid */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }

/* Project detail */
.project-detail__progress { margin-bottom: 20px; }
.project-detail__progress label { font-size: 14px; font-weight: 500; display: block; margin-bottom: 6px; }

/* Notes */
.note-item { padding: 12px 0; border-bottom: 1px solid #f1f5f9; }
.note-item__header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.note-item__content { font-size: 14px; }
.note-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--color-border); }

/* Activity */
.activity-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #f1f5f9; font-size: 14px; }
.activity-row__action { font-weight: 500; min-width: 80px; }
.activity-row__action--created { color: var(--color-success); }
.activity-row__action--updated { color: var(--color-blue); }
.activity-row__action--completed { color: var(--color-primary); }
.activity-row__action--deleted { color: var(--color-danger); }
.activity-row__action--archived { color: var(--color-text-muted); }
.activity-row__name { flex: 1; }
.activity-row__time { color: var(--color-text-muted); font-size: 14px; }

/* Filters */
.filters-bar { margin-bottom: 16px; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Search */
.search-form { display: flex; gap: 12px; }
.search-form .form-control { flex: 1; }

/* Empty state */
.empty { text-align: center; color: var(--color-text-muted); padding: 24px; font-size: 14px; }
.empty-state { text-align: center; padding: 48px; color: var(--color-text-muted); }
.empty-state p { margin-bottom: 16px; }

/* Text helpers */
.text-muted { color: var(--color-text-muted); }
.text-red { color: var(--color-danger) !important; }
.text-sm { font-size: 14px; }
.text-mono { font-family: 'SF Mono', 'Consolas', monospace; font-size: 14px; }
.font-bold { font-weight: 600; }
.d-block { display: block; }
.mt-lg { margin-top: 24px; }
.text-pre { white-space: pre-wrap; font-size: 14px; }

/* Dashboard grid */
.dashboard__grid { display: grid; grid-template-columns: 1fr 1.5fr; gap: 16px; }
.dashboard__col { min-width: 0; }

/* Auth page (login) */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--color-bg); padding: 20px; }
.auth-card { background: var(--color-card); border: 1px solid var(--color-border); border-radius: 14px; padding: 40px; box-shadow: var(--shadow-lg); text-align: center; max-width: 400px; width: 100%; }
.auth-card__header { margin-bottom: 24px; }
.auth-card__header h1 { font-size: 22px; margin-top: 12px; font-weight: 700; }
.auth-card__subtitle { font-size: 14px; color: var(--color-text-muted); margin-top: 4px; }
.auth-card__desc { font-size: 14px; color: var(--color-text-muted); margin-top: 8px; line-height: 1.4; }
.auth-card__footer { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--color-border); font-size: 14px; color: var(--color-text-muted); }
.auth-card__footer strong { color: var(--color-text); }

.alert { padding: 10px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; }
.alert--error { background: var(--color-red-soft); color: var(--color-danger); border: 1px solid var(--color-danger); }
.alert--success { background: var(--color-green-soft); color: var(--color-success); border: 1px solid var(--color-success); }
.alert--warning { background: #fffbeb; color: #92400e; border: 1px solid #f59e0b; }
.alert--danger { background: #fef2f2; color: #b91c1c; border: 1px solid #ef4444; }
.alert--info { background: #ecfeff; color: #155e75; border: 1px solid #06b6d4; }
.alert__title { font-weight: 600; margin-bottom: 2px; }
.alert__message { font-size: 14px; }

/* Client ecosystem (people / LPR cards) */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.person-card { background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.person-card__header { padding: 16px 20px; border-bottom: 1px solid var(--color-border); display: flex; gap: 14px; align-items: center; }
.person-card__body { padding: 14px 20px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.person-card__footer { padding: 12px 20px; border-top: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; }
.avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--color-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; flex-shrink: 0; }
.avatar--lg { width: 64px; height: 64px; font-size: 22px; }
.kv-row { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; }
.kv-row__key { color: var(--color-text-muted); min-width: 120px; flex-shrink: 0; }
.kv-row__value { min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; padding: 2px 10px; border-radius: 999px; background: #f1f5f9; color: var(--color-text-muted); }
.chip--primary { background: rgba(59, 130, 246, 0.12); color: #1d4ed8; }
.money-highlight { font-size: 15px; font-weight: 700; color: var(--color-success); }
.msg-item { padding: 12px 0; border-bottom: 1px solid #f1f5f9; }
.msg-item:last-child { border-bottom: none; }
.msg-item__header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.msg-item__content { font-size: 14px; line-height: 1.5; }
.msg-bubble { background: #f1f5f9; border-radius: 12px; padding: 10px 14px; max-width: 520px; }
.msg-bubble--in { background: #eff6ff; border-left: 3px solid #3b82f6; }
.msg-bubble--out { background: #f0fdf4; border-left: 3px solid #22c55e; }
.ai-prompt-box { background: #0f172a; color: #e2e8f0; border-radius: var(--radius-sm); padding: 14px 16px; font-family: 'SF Mono', 'Consolas', monospace; font-size: 14px; line-height: 1.55; white-space: pre-wrap; max-height: 320px; overflow: auto; }

/* Auth state (already logged in) */
.auth-state { margin-top: 8px; text-align: center; }
.auth-state-avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--color-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; margin: 0 auto 10px; }
.auth-state-label { font-size: 14px; color: var(--color-text-muted); margin-bottom: 2px; }
.auth-state-name { font-weight: 600; font-size: 16px; }
.auth-state-role { font-size: 14px; color: var(--color-text-muted); margin-bottom: 16px; }
.auth-state-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.auth-state__logout-all { text-align: center; margin-top: 12px; }

/* Account list (login page) */
.account-list { text-align: left; }
.account-list__title { font-size: 14px; font-weight: 600; color: var(--color-text-muted); margin-bottom: 12px; text-align: center; }
.account-item-form { margin-bottom: 4px; }
.account-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-card);
    cursor: pointer;
    font-size: 14px;
    text-align: left;
    transition: all 0.15s;
    margin-bottom: 4px;
}
.account-item:hover { background: var(--color-bg); border-color: var(--color-primary); }
.account-item--add { border: 1px dashed var(--color-border); background: transparent; margin-top: 0; }
.account-item--add:hover { border-color: var(--color-primary); }
.account-item__avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--color-primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 17px; flex-shrink: 0;
}
.account-item__avatar--add { background: transparent; color: var(--color-text-muted); border: 2px dashed var(--color-text-muted); }
.account-item__info { display: flex; flex-direction: column; flex: 1; min-width: 0; overflow: hidden; }
.account-item__name { font-weight: 500; font-size: 14px; }
.account-item__email { font-size: 14px; color: var(--color-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-item__role { font-size: 14px; color: var(--color-text-muted); white-space: nowrap; padding-left: 8px; }
.login-back-btn {
    display: inline-flex; align-items: center; gap: 4px;
    background: none; border: none; cursor: pointer;
    color: var(--color-primary); font-size: 14px; padding: 0; margin-bottom: 16px;
}
.login-back-btn:hover { color: var(--color-primary-hover); }
.login-form-wrapper { text-align: left; }

/* Form checkbox */
.form-check { display: flex; align-items: center; gap: 8px; margin: 12px 0 4px; }
.form-check input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; accent-color: var(--color-primary); }
.form-check label { color: var(--color-text-muted); font-size: 14px; cursor: pointer; }

/* User avatars */
.user-avatar-xs {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}
.user-avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

/* Account switcher (topbar) */
.topbar__user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 4px 8px 4px 4px;
    cursor: pointer;
    font-size: 14px;
    color: var(--color-text);
    transition: all 0.15s;
}
.topbar__user-btn:hover { background: #f1f5f9; }

/* Account menu dropdown */
.account-menu {
    position: absolute;
    top: 100%;
    right: 0;
    width: 320px;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    display: none;
    margin-top: 8px;
}
.account-menu--open { display: block; }
.account-menu__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
}
.account-menu__name { font-weight: 600; font-size: 14px; }
.account-menu__email { font-size: 14px; color: var(--color-text-muted); }
.account-menu__divider { height: 1px; background: var(--color-border); margin: 0; }
.account-menu__section { padding: 8px 0; }
.account-menu__section-title { font-size: 14px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); padding: 4px 16px; font-weight: 600; }
.account-menu__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    font-size: 14px;
    color: var(--color-text);
    text-decoration: none;
    transition: background 0.1s;
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
}
.account-menu__item:hover { background: #f1f5f9; text-decoration: none; }
.account-menu__item--add { color: var(--color-primary); }
.account-menu__item--danger { color: var(--color-danger); }
.account-menu__footer { padding: 8px 0; }

/* User cell */
.user-cell { display: flex; align-items: center; gap: 8px; }

/* Card danger */
.card--danger { border-color: var(--color-danger); }
.card--danger .card__header h3 { color: var(--color-danger); }

/* Inline form */
.inline-form { display: inline; }

/* Table actions */
.table-actions { display: flex; gap: 4px; flex-wrap: wrap; }

/* Table empty */
.table-empty { text-align: center; color: var(--color-text-muted); padding: 24px; font-size: 14px; }
.table-scroll { overflow-x: auto; }

/* Margin helper */
.mt-1 { margin-top: 12px; }

/* Auth state (already logged in on login page) */
.auth-state { margin-top: 16px; padding: 16px; background: #f8fafc; border: 1px solid var(--color-border); border-radius: 12px; text-align: center; }
.auth-state-avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--color-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; margin: 0 auto 10px; }
.auth-state-label { font-size: 14px; color: var(--color-text-muted); margin-bottom: 2px; }
.auth-state-name { font-weight: 600; font-size: 15px; }
.auth-state-email { font-size: 14px; color: var(--color-text-muted); margin-bottom: 12px; }
.auth-state-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.auth-state-logout-all { text-align: center; margin-top: 12px; }

.btn--outline { background: transparent; }
.btn--danger-text { color: var(--color-danger); border-color: var(--color-danger); }
.btn--danger-text:hover { background: #fef2f2; }

.btn--link-danger { border: none; background: none; cursor: pointer; color: var(--color-danger); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; padding: 0; }
.btn--link-danger:hover { color: #dc2626; }

.btn--secondary { background: #f1f5f9; border-color: var(--color-border); color: var(--color-text); }
.btn--secondary:hover { background: #e2e8f0; }

.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger) !important; }

/* Switch toggle */
.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    cursor: pointer;
    border-bottom: 1px solid var(--color-border);
}
.switch-row:last-child { border-bottom: none; }
.switch-text { flex: 1; }
.switch-text strong { display: block; font-size: 14px; margin-bottom: 2px; }
.switch-text span { display: block; font-size: 14px; color: var(--color-text-muted); }
.switch {
    width: 48px;
    height: 26px;
    background: #cbd5e0;
    border-radius: 13px;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}
.switch.on { background: var(--color-primary); }
.switch::after {
    content: '';
    width: 22px;
    height: 22px;
    background: #fff;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.switch.on::after { transform: translateX(22px); }

/* Page header tabs */
.page-header__tabs { display: flex; gap: 4px; margin: 12px 0; }
.tab-link {
    padding: 6px 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--color-text-muted);
    text-decoration: none;
    transition: all 0.15s;
}
.tab-link:hover { background: #f1f5f9; text-decoration: none; }
.tab-link--active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.tab-link--active:hover { background: var(--color-primary-hover); }

/* Exchange tabs */
.exchange-tabs { display: flex; gap: 4px; margin-bottom: 0; background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 4px; }
.exchange-tab {
    display: flex; align-items: center; gap: 6px; padding: 10px 20px;
    border: none; background: transparent; cursor: pointer; font-size: 14px; font-weight: 500;
    color: var(--color-text-muted); border-radius: var(--radius-sm); transition: all 0.15s;
}
.exchange-tab:hover { background: var(--color-bg); color: var(--color-text); }
.exchange-tab--active { background: var(--color-primary); color: #fff; }
.exchange-tab--active:hover { background: var(--color-primary-hover); }
.exchange-content { margin-top: 16px; }
.exchange-pane { display: none; }
.exchange-pane--active { display: block; }

/* Import upload zone */
.upload-zone {
    border: 2px dashed var(--color-border); border-radius: var(--radius);
    padding: 32px; text-align: center; cursor: pointer; transition: all 0.15s;
    background: var(--color-bg);
}
.upload-zone:hover { border-color: var(--color-primary); background: var(--color-card); }

/* Sync platform card */
.sync-platform-card {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border: 1px solid var(--color-border);
    border-radius: var(--radius); background: var(--color-card);
}
.sync-platform-info { display: flex; flex-direction: column; gap: 2px; }
.sync-platform-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* Import stats */
.import-stats .info-row { padding: 8px 0; }

/* Checkbox inline */
.checkbox-group { display: flex; gap: 20px; flex-wrap: wrap; }
.checkbox-inline { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.checkbox-inline input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--color-primary); }

/* Code block */
.code-block {
    background: var(--color-sidebar); color: #e2e8f0; padding: 16px;
    border-radius: var(--radius-sm); font-family: 'SF Mono', 'Consolas', monospace;
}

/* Social cards */
.social-card {
    background: var(--color-card); border: 1px solid var(--color-border);
    border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
    display: flex; flex-direction: column; gap: 10px;
    border-top: 3px solid var(--color-border);
}
.social-card.status-green { border-top-color: var(--color-success); }
.social-card.status-blue { border-top-color: var(--color-blue); }
.social-card.status-red { border-top-color: var(--color-danger); }
.social-card__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.social-card__name { font-size: 16px; font-weight: 600; }
.social-card__name a { color: var(--color-text); }
.social-card__tags { display: flex; gap: 4px; flex-wrap: wrap; }
.social-card__desc { font-size: 14px; color: var(--color-text-muted); }
.social-card__result { font-size: 14px; }
.social-card__meta { display: flex; gap: 6px; flex-wrap: wrap; font-size: 14px; color: var(--color-text-muted); }
.social-card__meta span {
    background: var(--color-bg); border-radius: 4px; padding: 2px 8px;
}
.social-card__status {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 14px; border-top: 1px solid var(--color-border); padding-top: 10px;
}
.status-label { color: var(--color-text-muted); }
.status-date { font-weight: 600; }
.status-date.status-green { color: var(--color-success); }
.status-date.status-blue { color: var(--color-blue); }
.status-date.status-red { color: var(--color-danger); }
.social-card__actions { display: flex; gap: 8px; align-items: center; margin-top: auto; }

/* Notifications bell + dropdown */
.topbar__notif { position: relative; }
.topbar__notif-btn {
    position: relative;
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
    background: none; border: 1px solid var(--color-border);
    border-radius: var(--radius); cursor: pointer;
    color: var(--color-text); transition: all 0.15s;
}
.topbar__notif-btn:hover { background: #f1f5f9; }
.notif-badge {
    position: absolute; top: -4px; right: -4px;
    min-width: 18px; height: 18px; padding: 0 5px;
    background: var(--color-danger); color: #fff;
    border-radius: 9px; font-size: 14px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    line-height: 1; box-shadow: 0 1px 3px rgba(239,68,68,0.3);
}
.notif-menu {
    position: absolute; top: 100%; right: 0;
    width: 340px; max-height: 480px;
    background: var(--color-card); border: 1px solid var(--color-border);
    border-radius: 14px; box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    z-index: 200; display: none; margin-top: 8px;
    overflow: hidden; flex-direction: column;
}
.notif-menu--open { display: flex; }
.notif-menu__header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border-bottom: 1px solid var(--color-border);
}
.notif-menu__title { font-weight: 600; font-size: 14px; }
.notif-menu__read-all { border: none; background: none; cursor: pointer; color: var(--color-primary); font-size: 14px; padding: 0; }
.notif-menu__list { overflow-y: auto; }
.notif-menu__item {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 16px; border-bottom: 1px solid var(--color-border);
    text-decoration: none; color: var(--color-text); transition: background 0.1s;
}
.notif-menu__item:hover { background: #f1f5f9; text-decoration: none; }
.notif-menu__item--read { opacity: 0.65; }
.notif-menu__dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.notif-menu__text { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.notif-menu__body { font-size: 14px; color: var(--color-text-muted); }
.notif-menu__time { font-size: 14px; color: var(--color-text-muted); }
.notif-menu__empty { padding: 24px 16px; text-align: center; color: var(--color-text-muted); font-size: 14px; }
.notif-menu__footer {
    display: block; text-align: center; padding: 12px 16px;
    border-top: 1px solid var(--color-border);
    font-size: 14px; color: var(--color-primary); text-decoration: none;
}
.notif-menu__footer:hover { background: #f1f5f9; text-decoration: none; }

/* Sidebar badge */
.sidebar__badge {
    margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
    background: var(--color-danger); color: #fff;
    border-radius: 10px; font-size: 14px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 1px 3px rgba(239,68,68,0.3);
}

/* Notifications page */
.notif-row {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px 16px; border-bottom: 1px solid var(--color-border);
    border-left: 3px solid transparent;
}
.notif-row:last-child { border-bottom: none; }
.notif-row--unread { background: rgba(59, 130, 246, 0.04); }
.notif-row--read { opacity: 0.7; }
.notif-row__icon {
    width: 28px; height: 28px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.notif-row__content { flex: 1; min-width: 0; }
.notif-row__title { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.notif-row__body { font-size: 14px; color: var(--color-text-muted); margin-top: 2px; }
.notif-row__meta { display: flex; gap: 8px; align-items: center; margin-top: 6px; font-size: 14px; color: var(--color-text-muted); }
.notif-row__link { color: var(--color-primary); }
.notif-row__actions { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }
.notif-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--color-primary); display: inline-block;
}
.notif-type-badge {
    font-size: 14px; padding: 2px 8px; border-radius: 4px;
    background: var(--color-bg); color: var(--color-text-muted); font-weight: 600;
}

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* Safe areas for standalone PWA (notch / home indicator) */
@supports (padding: max(0px)) {
    .bottom-nav { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); padding-bottom: env(safe-area-inset-bottom); height: auto; min-height: 58px; }
}

/* Bottom navigation (Android-style) — hidden on desktop */
.bottom-nav {
    display: none;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: 58px;
    background: var(--color-page, var(--color-card));
    border-top: 1px solid var(--color-border);
    z-index: 120;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
}
.bottom-nav__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 2px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: 10px;
    min-width: 0;
}
.bottom-nav__item:hover { background: var(--color-bg); color: var(--color-text); text-decoration: none; }
.bottom-nav__item svg { flex-shrink: 0; }
.bottom-nav__item--active { color: var(--color-primary); }
.bottom-nav__item--active svg { color: var(--color-primary); }

/* Sidebar as a slide-in drawer on mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 140;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.sidebar-overlay--visible { opacity: 1; }
.sidebar__close { display: none; }

/* Responsive */
@media (max-width: 900px) {
    .content { padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px)); }

    /* Bottom nav appears */
    .bottom-nav { display: flex; }

    /* Sidebar becomes a left drawer */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(.2,.8,.3,1);
        box-shadow: none;
        z-index: 160;
    }
    .sidebar-overlay { z-index: 150; }
    .bottom-nav { z-index: 130; }
    body.sidebar-open .sidebar { transform: translateX(0); box-shadow: 0 4px 30px rgba(0,0,0,0.35); }
    body.sidebar-open { overflow: hidden; }
    body.sidebar-open .sidebar-overlay { display: block; }
    .sidebar__close {
        display: flex; align-items: center; justify-content: center;
        position: absolute; top: 10px; right: 10px;
        width: 34px; height: 34px; border-radius: 8px;
        background: rgba(255,255,255,0.08); color: #cbd5e1;
        cursor: pointer; z-index: 5;
    }
    .sidebar__close:hover { color: #fff; background: rgba(255,255,255,0.16); }

    .main { margin-left: 0; }

    /* Topbar burger visible on mobile */
    .topbar__burger { display: inline-flex; }
    .topbar { padding: 0 16px; gap: 8px; padding-top: env(safe-area-inset-top, 0px); height: auto; min-height: var(--topbar-height); }
    .topbar__search { display: none; }
    .topbar__search-btn { display: none; }
    .topbar__user-btn span:not(.user-avatar-xs) { display: none; }
    .topbar__user-btn svg { display: none; }
    .topbar__actions { gap: 8px; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard__grid { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; gap: 0; }
    .page-header { flex-direction: column; gap: 12px; }
    .directions-grid { grid-template-columns: 1fr; }
    .people-grid { grid-template-columns: 1fr; }
    .social-card { padding: 16px; }
    .detail-label { width: 140px; }
}

@media (max-width: 768px) {
    /* Контент: компактные боковые отступы 16px */
    .content { padding-left: 16px; padding-right: 16px; }

    /* Таблицы -> карточки на мобильных (без горизонтального скролла) */
    .table,
    .table--full,
    .table--striped {
        display: block;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        overflow: visible;
    }
    .table thead { display: none; }
    .table tbody { display: block; }

    .table tr {
        display: block;
        margin: 0 0 14px 0;
        padding: 14px 16px;
        background: var(--color-card);
        border: 1px solid var(--color-border);
        border-radius: 14px;
        box-shadow: var(--shadow);
    }
    .table tr:last-child { margin-bottom: 0; }
    .table tbody tr:hover td { background: transparent; }

    .table td {
        display: block;
        padding: 6px 0;
        border: none;
        font-size: 14px;
    }
    .table td:first-child {
        font-weight: 700;
        font-size: 15px;
        padding: 0 0 6px 0;
    }
    .table td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-weight: 700;
        font-size: 12px;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: var(--color-text-muted);
        margin-bottom: 2px;
    }
    .table td:first-child::before,
    .table td[colspan]::before { display: none; }
    .table th { display: block; }

    /* detail-таблицы (пары подпись-значение) */
    .detail-table tr { display: block; padding: 8px 0; border-bottom: 1px solid var(--color-border); }
    .detail-table tr:last-child { border-bottom: none; }
    .detail-table td { display: block; padding: 2px 0; border: none; }
    .detail-table .detail-label { width: auto; margin-bottom: 2px; white-space: normal; }

    html, body { overflow-x: hidden; }
}

/* Задание 9: Светофор ситуаций */
.signal {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--color-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    white-space: nowrap;
    cursor: help;
}
.signal__dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.signal--red { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.35); color: #dc2626; }
.signal--yellow { background: rgba(245,158,11,0.1); border-color: rgba(245,158,11,0.35); color: #d97706; }
.signal--green { background: rgba(34,197,94,0.1); border-color: rgba(34,197,94,0.35); color: #16a34a; }
.signal--gray { background: var(--color-bg); border-color: var(--color-border); color: var(--color-text-muted); }
[data-theme="dark"] .signal--red { color: #f87171; }
[data-theme="dark"] .signal--yellow { color: #fbbf24; }
[data-theme="dark"] .signal--green { color: #4ade80; }
.signal-reason { font-size: 14px; color: var(--color-text); }

/* Задание 9: Компании */
.companies-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.company-card { background: var(--color-card); border: 1px solid var(--color-border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.company-card__header { padding: 16px 20px; border-bottom: 1px solid var(--color-border); display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.company-card__body { padding: 14px 20px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.company-card__footer { padding: 12px 20px; border-top: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; }

/* Задание 9: Сырые данные / вложения */
.attachments { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.attachment { display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius-sm); }
.attachment__icon { font-size: 18px; line-height: 1.2; }
.attachment__title { font-size: 14px; font-weight: 600; color: var(--color-text-muted); }
.attachment__content { font-size: 14px; white-space: pre-wrap; }

/* Пагинация */
.pagination { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pagination span, .pagination a {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 36px; height: 36px; padding: 0 10px;
    border-radius: 10px; font-size: 14px; font-weight: 500; text-decoration: none;
    border: 1.5px solid var(--color-border); background: var(--color-card);
    color: var(--color-text); transition: all 0.2s cubic-bezier(.4,0,.2,1);
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    line-height: 1;
}
.pagination a:hover { border-color: var(--color-primary); color: var(--color-primary); box-shadow: 0 2px 8px rgba(59,130,246,0.12); transform: translateY(-1px); }
.pagination .active span { background: var(--color-primary); color: #fff; border-color: var(--color-primary); box-shadow: 0 2px 8px rgba(59,130,246,0.25); }
.pagination .disabled span { color: var(--color-text-muted); opacity: .4; cursor: default; border-color: var(--color-border); }
.pagination .dots { border: none; background: none; min-width: auto; color: var(--color-text-muted); }

/* Сортировка — подсветка активного столбца */
table th a { transition: color .15s; }
table th a:hover { color: var(--color-primary) !important; }

/* Kebab menu (3-dot dropdown) */
.kebab { position: relative; display: inline-block; flex-shrink: 0; }
.kebab__btn {
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
    background: var(--color-card); cursor: pointer; color: var(--color-text-muted);
    transition: all 0.15s; font-size: 16px; letter-spacing: 1px; padding: 0; line-height: 1;
}
.kebab__btn:hover { background: var(--color-bg); color: var(--color-text); border-color: var(--color-text-muted); }
.kebab__dropdown {
    position: absolute; top: 100%; right: 0; margin-top: 4px;
    background: var(--color-card); border: 1px solid var(--color-border);
    border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 150;
    min-width: 160px; display: none; overflow: hidden;
}
.kebab__dropdown--open { display: block; }
.kebab__item {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 14px; font-size: 14px; font-weight: 500;
    color: var(--color-text); text-decoration: none;
    background: none; border: none; cursor: pointer;
    width: 100%; text-align: left; transition: background 0.1s;
}
.kebab__item:hover { background: var(--color-bg); text-decoration: none; }
.kebab__item--danger { color: var(--color-danger); }
.kebab__item--danger:hover { background: var(--color-red-soft); }
.kebab__divider { height: 1px; background: var(--color-border); margin: 0; }
.kebab__item svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Person list photo column */
.person-photo { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 1px solid var(--color-border); flex-shrink: 0; }
.person-photo-placeholder { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 16px; flex-shrink: 0; }

/* Relation list photo */
.rel-photo { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; border: 1px solid var(--color-border); flex-shrink: 0; }
.rel-photo-placeholder { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; flex-shrink: 0; }
