/* DXCISION Admin — Apple Health–inspired layout (uses dxcision-theme.css tokens) */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--panel);
    color: var(--ink);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.47;
    -webkit-font-smoothing: antialiased;
}

header {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-card);
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 18px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.header-copy h1 {
    margin: 0;
    font-size: clamp(22px, 3vw, 26px);
    font-weight: 700;
    letter-spacing: -0.03em;
}

.header-copy p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    min-height: 40px;
    border: 0;
    border-radius: 999px;
    padding: 0 16px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn:not(:disabled):active {
    transform: scale(0.98);
}

.btn-ghost {
    background: var(--field);
    color: var(--ink);
}

.btn-primary {
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: 0 4px 14px var(--teal-glow);
}

.btn-danger {
    background: var(--red-soft);
    color: var(--red);
}

.btn-success {
    background: var(--green-soft);
    color: var(--green);
}

main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 18px 32px;
    display: grid;
    gap: 12px;
}

.status-bar {
    border-radius: var(--radius-lg);
    padding: 14px 18px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: var(--shadow-card);
}

.status-bar.loading {
    background: var(--surface);
    border: none;
    color: var(--muted);
}

.status-bar.notice {
    background: var(--amber-soft);
    color: var(--amber);
    border: none;
}

.status-bar.success {
    background: var(--green-soft);
    color: var(--green);
    border: none;
}

.status-bar.error {
    background: var(--red-soft);
    color: var(--red);
    border: none;
}

.status-bar.hidden {
    display: none;
}

.admin-section {
    background: var(--surface);
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    background: transparent;
}

.section-header h2 {
    margin: 0;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    font-weight: 600;
}

.section-toggle {
    background: var(--field);
    border: none;
    color: var(--muted-deep);
    min-height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.section-body {
    padding: 16px 18px 18px;
}

.section-body.collapsed {
    display: none;
}

.stats-groups {
    display: grid;
    gap: 18px;
}

.stats-group-label {
    margin: 0 0 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--muted);
    letter-spacing: 0.05em;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.card {
    background: var(--panel);
    border: none;
    border-radius: var(--radius-md);
    padding: 16px;
    min-width: 0;
    box-shadow: inset 0 0 0 1px var(--line);
}

.card span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.card strong {
    display: block;
    margin-top: 8px;
    font-size: clamp(20px, 2.4vw, 26px);
    font-weight: 700;
    line-height: 1.1;
    word-break: break-word;
    letter-spacing: -0.02em;
}

.card.accent strong {
    color: var(--teal);
}

.card.warn strong {
    color: var(--red);
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.toolbar-meta {
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
}

input[type="search"],
input[type="text"] {
    width: 100%;
    max-width: 420px;
    min-height: 42px;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0 12px 0 36px;
    background: var(--field);
    color: var(--ink);
    font: inherit;
    font-weight: 500;
    outline: none;
}

input[type="search"]:focus,
input[type="text"]:focus {
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--teal-soft), inset 0 0 0 1px rgba(0, 168, 155, 0.35);
}

input[type="search"] {
    background: var(--field) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238e8e93' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242 1.156a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E") no-repeat 12px center;
}

.table-wrap {
    overflow: auto;
    border: none;
    border-radius: var(--radius-md);
    background: var(--panel);
    box-shadow: inset 0 0 0 1px var(--line);
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 760px;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 12px;
    text-align: left;
    vertical-align: middle;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    color: var(--muted);
    background: var(--panel);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    white-space: nowrap;
}

tr:last-child td {
    border-bottom: 0;
}

tbody tr:hover {
    background: var(--field);
}

.cell-stack {
    display: grid;
    gap: 2px;
}

.cell-sub {
    color: var(--muted);
    font-size: 12px;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 10px;
    font-weight: 600;
    font-size: 11px;
    text-transform: capitalize;
    white-space: nowrap;
}

.badge-role {
    background: var(--teal-soft);
    color: var(--teal-dark);
}

.badge-admin {
    background: var(--green-soft);
    color: var(--green);
}

.badge-active {
    background: var(--green-soft);
    color: var(--green);
}

.badge-inactive {
    background: var(--red-soft);
    color: var(--red);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 180px;
}

.actions .btn {
    min-height: 32px;
    padding: 0 12px;
    font-size: 12px;
}

.user-cards {
    display: none;
    gap: 10px;
}

.user-card {
    border: none;
    border-radius: var(--radius-md);
    padding: 16px;
    background: var(--surface);
    box-shadow: var(--shadow-card);
    display: grid;
    gap: 10px;
}

.user-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.user-card-head strong {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
}

.user-card-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
    font-size: 13px;
}

.user-card-grid dt {
    margin: 0;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 600;
}

.user-card-grid dd {
    margin: 2px 0 0;
    word-break: break-word;
}

.feedback-columns {
    display: grid;
    gap: 12px;
}

.feedback-list {
    display: grid;
    gap: 10px;
}

.feedback-item {
    border: none;
    border-radius: var(--radius-md);
    padding: 14px;
    background: var(--panel);
    box-shadow: inset 0 0 0 1px var(--line);
}

.feedback-group {
    border: none;
    border-radius: var(--radius-md);
    background: var(--panel);
    box-shadow: inset 0 0 0 1px var(--line);
    overflow: hidden;
}

.feedback-group > summary {
    cursor: pointer;
    padding: 12px 14px;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.feedback-group > summary::-webkit-details-marker {
    display: none;
}

.feedback-group > summary::before {
    content: "▶";
    font-size: 10px;
    color: var(--muted);
    transition: transform 0.15s;
    flex-shrink: 0;
}

.feedback-group[open] > summary::before {
    transform: rotate(90deg);
}

.feedback-group-body {
    border-top: 1px solid var(--line);
    padding: 8px 12px 12px;
    display: grid;
    gap: 8px;
}

.feedback-group-body .feedback-item {
    background: var(--surface);
}

.badge-red {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--red-soft);
    color: var(--red);
    border-radius: 999px;
    padding: 2px 9px;
    font-weight: 700;
    font-size: 12px;
    min-width: 22px;
}

.bad-review-border {
    box-shadow: inset 0 0 0 1px rgba(255, 59, 48, 0.25);
    background: var(--red-soft);
}

.bad-review-border .feedback-item {
    background: var(--surface);
}

.muted {
    color: var(--muted);
}

.empty-state {
    border: none;
    border-radius: var(--radius-md);
    padding: 28px 16px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    background: var(--panel);
    box-shadow: inset 0 0 0 1px var(--line);
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.filter-chip {
    min-height: 34px;
    border: none;
    background: var(--field);
    color: var(--muted-deep);
    border-radius: 999px;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.filter-chip.active {
    background: var(--teal-soft);
    color: var(--teal-dark);
}

.btn-manage {
    background: var(--teal-soft);
    color: var(--teal-dark);
    border: none;
    min-height: 34px;
    padding: 0 12px;
    font-size: 13px;
}

.cost-value {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 16px;
}

.modal.hidden {
    display: none !important;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: var(--overlay);
}

.modal-panel {
    position: relative;
    width: min(560px, 100%);
    max-height: min(90vh, 760px);
    overflow: auto;
    background: var(--surface);
    border: none;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-float);
}

.modal-header,
.modal-footer {
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
}

.modal-footer {
    border-bottom: 0;
    border-top: 1px solid var(--line);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.modal-close {
    background: var(--field);
    border: 0;
    width: 32px;
    height: 32px;
    min-height: 32px;
    border-radius: 999px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: var(--muted);
    padding: 0;
}

.modal-body {
    padding: 16px 18px;
    display: grid;
    gap: 14px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.detail-item {
    background: var(--panel);
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px;
    box-shadow: inset 0 0 0 1px var(--line);
}

.detail-item span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.detail-item strong {
    display: block;
    margin-top: 6px;
    font-size: 15px;
    font-weight: 600;
    word-break: break-word;
}

.danger-zone {
    border: none;
    background: var(--red-soft);
    border-radius: var(--radius-md);
    padding: 14px;
    box-shadow: inset 0 0 0 1px rgba(255, 59, 48, 0.2);
}

.danger-zone h4 {
    margin: 0 0 8px;
    color: var(--red);
    font-size: 14px;
    font-weight: 600;
}

.danger-zone p {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 13px;
}

.hidden {
    display: none !important;
}

@media (min-width: 900px) {
    .feedback-columns {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    main {
        padding: 16px;
    }

    .header-inner {
        padding: 16px;
    }

    .table-wrap {
        display: none;
    }

    .user-cards {
        display: grid;
    }

    .grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 480px) {
    .grid,
    .user-card-grid {
        grid-template-columns: 1fr;
    }

    .header-actions {
        width: 100%;
    }

    .header-actions .btn {
        flex: 1 1 auto;
    }

    .header-actions .theme-switch {
        flex: 0 0 auto;
    }
}
