* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-family: Arial, sans-serif; font-size: 13px; background: linear-gradient(180deg, #f5f8fc, #eef2f8); color: #1f2937; }
.crm-shell { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.crm-sidebar { background: #111827; color: #f9fafb; padding: 28px 24px; display: flex; flex-direction: column; justify-content: space-between; gap: 24px; }
.crm-sidebar__content { display: grid; gap: 18px; align-content: start; }
.crm-sidebar h1, .crm-header h2, .auth-card h1 { margin: 0; }
.crm-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.crm-logo { width: 52px; height: 52px; object-fit: contain; border-radius: 14px; background: rgba(255,255,255,.04); padding: 4px; }
.crm-kicker { text-transform: uppercase; letter-spacing: .08em; font-size: 12px; color: #f59e0b; margin: 0 0 8px; }
.crm-muted { color: #6b7280; line-height: 1.5; }
.crm-sidebar .crm-muted { color: #cbd5e1; }
.crm-nav { display: grid; gap: 8px; margin-top: 16px; }
.crm-nav a { color: #f9fafb; text-decoration: none; padding: 13px 15px; border-radius: 12px; background: rgba(255,255,255,.04); font-size: 15px; font-weight: 700; }
.crm-nav a.active, .crm-nav a:hover { background: #f59e0b; color: #111827; }
.crm-nav__logout { margin: 0; }
.crm-nav__logout-button {
    width: 100%;
    border: 0;
    cursor: pointer;
    text-align: left;
    padding: 13px 15px;
    border-radius: 12px;
    background: rgba(255,255,255,.04);
    color: #f9fafb;
    font-size: 15px;
    font-weight: 700;
}
.crm-nav__logout-button:hover {
    background: #f59e0b;
    color: #111827;
}
.crm-main { padding: 24px; }
.crm-header { margin-bottom: 16px; }
.card, .stat-card, .auth-card { background: #fff; border: 1px solid #dbe3ef; border-radius: 18px; box-shadow: 0 14px 38px rgba(15,23,42,.06); }
.card { padding: 18px; margin-bottom: 18px; }
.form-card { max-width: 720px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 18px; margin-bottom: 24px; }
.stat-card { padding: 16px; }
.stat-card span { display: block; color: #6b7280; margin-bottom: 8px; }
.stat-card strong { font-size: 18px; word-break: break-word; }
.split-grid { display: grid; grid-template-columns: 360px 1fr; gap: 24px; }
.card-header, .page-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 9px 10px; border-bottom: 1px solid #e5e7eb; text-align: left; vertical-align: top; font-size: 12px; }
.table.compact th, .table.compact td { padding: 8px 10px; }
.table-wrap { overflow-x: auto; }
.table-wrap::-webkit-scrollbar { height: 10px; }
.table-wrap::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 999px; }
.table-wrap {
    border: 1px solid #dbe3ef;
    border-radius: 20px;
    background: #fff;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.8);
    margin-bottom: 12px;
}
.matrix-table thead tr:first-child th {
    background: #f59e0b;
    color: #111827;
    border-right: 1px solid rgba(17, 24, 39, 0.14);
}
.matrix-table thead tr:nth-child(2) th {
    background: #dcfce7;
    color: #14532d;
    border-right: 1px solid rgba(20, 83, 45, 0.12);
}
.matrix-table td, .matrix-table th {
    text-align: center;
    white-space: nowrap;
}
.matrix-table {
    margin: 0;
}
.matrix-table th, .matrix-table td {
    padding: 7px 8px;
}
.matrix-table--compact th,
.matrix-table--compact td {
    padding: 6px 7px;
    font-size: 11px;
}
.matrix-table td:nth-child(3), .matrix-table th:nth-child(3) {
    text-align: left;
}
.matrix-table td {
    background: #fff;
}
.matrix-table tbody tr:nth-child(even) td {
    background: #f8fafc;
}
.matrix-table tbody td:hover {
    background: #fff7ed;
}
.matrix-table tbody tr:last-child td {
    border-bottom: 0;
}
.matrix-table--sticky th:nth-child(1),
.matrix-table--sticky td:nth-child(1) {
    position: sticky;
    left: 0;
    z-index: 2;
    min-width: 56px;
}
.matrix-table--sticky th:nth-child(2),
.matrix-table--sticky td:nth-child(2) {
    position: sticky;
    left: 56px;
    z-index: 2;
    min-width: 72px;
}
.matrix-table--sticky th:nth-child(3),
.matrix-table--sticky td:nth-child(3) {
    position: sticky;
    left: 128px;
    z-index: 2;
    min-width: 240px;
}
.matrix-table--sticky thead th {
    z-index: 4;
}
.matrix-table--sticky tbody td:nth-child(1),
.matrix-table--sticky tbody td:nth-child(2),
.matrix-table--sticky tbody td:nth-child(3) {
    box-shadow: 1px 0 0 #e5e7eb;
}
.matrix-actions {
    justify-content: center;
    min-width: 124px;
}
.matrix-position {
    display: inline-flex;
    min-width: 30px;
    justify-content: center;
    align-items: center;
    padding: 3px 7px;
    border-radius: 999px;
    background: #fff7ed;
    color: #9a3412;
    font-weight: 700;
}
.matrix-action-stack {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
}
.matrix-edit,
.matrix-delete {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 0;
}
.matrix-edit {
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #2563eb;
    text-decoration: none;
}
.matrix-delete {
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #dc2626;
    cursor: pointer;
}
.matrix-delete svg,
.matrix-edit svg {
    width: 12px;
    height: 14px;
    display: block;
}
.matrix-empty-action {
    color: #94a3b8;
    font-size: 12px;
}
.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}
.status-pill--live {
    color: #166534;
    background: #dcfce7;
}
.status-pill--muted {
    color: #475569;
    background: #e2e8f0;
}
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.button, .button-secondary, input, select { border-radius: 10px; font-size: 12px; }
.button, .button-secondary { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; border: 0; cursor: pointer; padding: 9px 13px; font-weight: 700; }
.button { background: #f59e0b; color: #111827; }
.button--large { padding: 11px 18px; font-size: 13px; }
.button--wide { min-width: 148px; white-space: nowrap; }
.button-secondary { background: #e5eefc; color: #1d4ed8; }
.button-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.button-secondary--soft { background: #f8fafc; color: #334155; border: 1px solid #dbe3ef; }
.button-link { background: none; border: 0; padding: 0; cursor: pointer; color: #1d4ed8; }
.button-link.danger { color: #b91c1c; }
.button-link.search-trigger {
    color: #b45309;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: #fff7ed;
    border: 1px solid #fdba74;
}
.button-link.search-trigger.is-loading {
    width: auto;
    padding: 0 10px;
    border-radius: 999px;
}
.button-link.search-trigger:disabled {
    opacity: .7;
    cursor: wait;
}
.search-icon { width: 16px; height: 16px; display: block; }
.full-width { width: 100%; }
.form-grid { display: grid; gap: 16px; }
label span { display: block; margin-bottom: 6px; font-weight: 700; }
input, select { width: 100%; border: 1px solid #cbd5e1; padding: 9px 11px; background: #fff; }
.filter-grid { display: grid; grid-template-columns: 1.2fr .9fr auto; gap: 16px; align-items: end; }
.table-filter { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.table-filter--premium {
    padding: 14px;
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid #e2e8f0;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.8);
}
.filter-field {
    min-width: 180px;
    flex: 1 1 180px;
}
.filter-field--small {
    min-width: 110px;
    flex: 0 0 110px;
}
.filter-field span {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #64748b;
}
.filter-field--search {
    flex: 1.4 1 280px;
}
.project-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 12px;
}
.project-toolbar__actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: nowrap;
}
.export-menu {
    position: relative;
}
.export-menu__panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 150px;
    display: grid;
    gap: 6px;
    padding: 8px;
    border: 1px solid #dbe3ef;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.12);
    z-index: 20;
}
.export-menu__option {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 12px;
    border-radius: 10px;
    background: #f8fafc;
    color: #334155;
    text-decoration: none;
    font-size: 12px;
    font-weight: 700;
}
.export-menu__option:hover {
    background: #e2e8f0;
}
.project-filters {
    width: min(100%, 980px);
    margin-left: auto;
}
.table-hint { color: #64748b; font-size: 11px; }
.page-actions--compact {
    margin-bottom: 0;
}
.table-link {
    color: #0f172a;
    font-weight: 700;
    text-decoration: none;
}
.table-link:hover {
    color: #b45309;
}
.table-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    color: #334155;
}
.table-checkbox input,
.row-checkbox {
    width: 15px;
    height: 15px;
    accent-color: #f59e0b;
}
.table-muted { color: #64748b; font-size: 11px; margin-top: 3px; }
.bulk-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    padding: 12px 14px;
    border: 1px solid #fde68a;
    border-radius: 14px;
    background: linear-gradient(180deg, #fffdf5 0%, #fff7ed 100%);
}
.bulk-actions__meta {
    display: grid;
    gap: 3px;
}
.bulk-actions__meta strong {
    font-size: 13px;
}
.bulk-actions__meta span {
    color: #78716c;
    font-size: 11px;
}
.bulk-actions__controls {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex-wrap: wrap;
}
.bulk-actions__controls textarea {
    min-width: 280px;
    min-height: 96px;
}
.filter-panel {
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}
.filter-panel summary {
    list-style: none;
    cursor: pointer;
    padding: 10px 14px;
    font-weight: 700;
    color: #334155;
}
.filter-panel summary::-webkit-details-marker { display: none; }
.filter-panel[open] summary { border-bottom: 1px solid #e2e8f0; }
.pagination-shell {
    margin-top: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 2px;
}
.pagination-shell::-webkit-scrollbar {
    height: 8px;
}
.pagination-shell::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}
.crm-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
    min-width: max-content;
    padding: 10px 12px;
    border: 1px solid #dbe3ef;
    border-radius: 14px;
    background: #fff;
}
.crm-pagination__meta {
    color: #64748b;
    font-size: 11px;
}
.crm-pagination__links {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    white-space: nowrap;
}
.crm-pagination__button,
.crm-pagination__page,
.crm-pagination__ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 32px;
    padding: 0 10px;
    border-radius: 10px;
    border: 1px solid #dbe3ef;
    background: #fff;
    color: #334155;
    text-decoration: none;
    font-size: 12px;
    font-weight: 700;
}
.crm-pagination__page.is-active {
    background: #f59e0b;
    border-color: #f59e0b;
    color: #111827;
}
.crm-pagination__button.is-disabled {
    opacity: .45;
    cursor: default;
}
.icon-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 999px;
    color: #2563eb;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    text-decoration: none;
}
.icon-action svg {
    width: 14px;
    height: 14px;
    display: block;
}
.icon-action--danger {
    color: #dc2626;
    background: #fef2f2;
    border-color: #fecaca;
}
.section-title { margin: 0 0 4px; font-size: 20px; }
textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    padding: 9px 11px;
    background: #fff;
    border-radius: 10px;
    font: inherit;
    resize: vertical;
}
.keyword-stack { display: grid; gap: 16px; }
.keyword-card { border: 1px solid #e5e7eb; border-radius: 16px; padding: 16px; }
.keyword-card__top { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.keyword-card__top p { margin: 6px 0 0; color: #6b7280; }
.form-card--wide { max-width: 1080px; }
.import-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}
.alert { padding: 14px 16px; border-radius: 12px; margin-bottom: 18px; }
.alert-success { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-error ul { margin: 8px 0 0 18px; }
.empty-state { text-align: center; color: #6b7280; padding: 20px 0; }
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(460px, 100%); padding: 28px; }
.demo-box { display: grid; gap: 4px; background: #fff7ed; border: 1px solid #fdba74; color: #9a3412; padding: 14px; border-radius: 14px; margin: 18px 0; }
.checkbox { display: flex; align-items: center; gap: 10px; }
.checkbox input { width: auto; }
.crm-toast {
    position: fixed; right: 22px; bottom: 22px; z-index: 9999; max-width: 360px;
    padding: 12px 14px; border-radius: 14px; color: #fff; background: #1d4ed8;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.2);
}
.crm-toast.error { background: #b91c1c; }
.crm-flash-toast {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 9999;
    min-width: 260px;
    max-width: 360px;
    display: grid;
    gap: 4px;
    padding: 12px 14px;
    border-radius: 14px;
    color: #fff;
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.22);
}
.crm-flash-toast strong {
    font-size: 13px;
}
.crm-flash-toast span {
    font-size: 12px;
}
.crm-flash-toast--success {
    background: linear-gradient(180deg, #059669, #047857);
}
.crm-flash-toast--info {
    background: linear-gradient(180deg, #2563eb, #1d4ed8);
}
@media (max-width: 960px) {
    .table-filter { width: 100%; }
    .table-filter input { flex: 1 1 100%; }
}
@media (max-width: 960px) {
    .crm-shell, .split-grid, .stats-grid, .filter-grid { grid-template-columns: 1fr; }
    .crm-main { padding: 20px; }
    .project-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .project-toolbar__actions {
        width: 100%;
        flex-wrap: wrap;
    }
    .export-menu {
        width: 100%;
    }
    .export-menu__panel {
        left: 0;
        right: auto;
        width: 100%;
    }
    .project-filters {
        width: 100%;
        margin-left: 0;
    }
    .import-grid {
        grid-template-columns: 1fr;
    }
    .table-filter--premium { width: 100%; }
    .page-actions--compact { width: 100%; justify-content: space-between; }
    .crm-brand { align-items: flex-start; }
    .bulk-actions {
        align-items: stretch;
        flex-direction: column;
    }
    .bulk-actions__controls {
        width: 100%;
    }
    .bulk-actions__controls textarea {
        min-width: 0;
        width: 100%;
    }
    .crm-pagination {
        min-width: 100%;
    }
    .matrix-table--sticky th:nth-child(1),
    .matrix-table--sticky td:nth-child(1),
    .matrix-table--sticky th:nth-child(2),
    .matrix-table--sticky td:nth-child(2),
    .matrix-table--sticky th:nth-child(3),
    .matrix-table--sticky td:nth-child(3) {
        position: static;
        left: auto;
    }
}
