/* Session Bot — admin console */
@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap");

:root {
    --surface-0: #f1f5f4;
    --surface-1: #ffffff;
    --surface-2: #f8faf9;
    --border: #e2e8e6;
    --border-strong: #cbd5d1;
    --text: #1c2925;
    --text-secondary: #4a5c56;
    --text-muted: #7a8f88;
    --accent: #0d9488;
    --accent-hover: #0f766e;
    --accent-muted: rgba(13, 148, 136, 0.12);
    --danger: #dc2626;
    --danger-muted: rgba(220, 38, 38, 0.08);
    --success: #059669;
    --success-muted: rgba(5, 150, 105, 0.1);
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgba(28, 41, 37, 0.05);
    --shadow-md: 0 4px 24px rgba(28, 41, 37, 0.08);
    --font: "DM Sans", system-ui, sans-serif;
    --mono: ui-monospace, "Cascadia Code", monospace;
}

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

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font);
    background: var(--surface-0);
    color: var(--text-secondary);
    line-height: 1.5;
    min-height: 100vh;
}

[hidden] {
    display: none !important;
}

/* —— Login —— */
.login-layout {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background:
        radial-gradient(ellipse 120% 80% at 50% -20%, rgba(13, 148, 136, 0.18), transparent),
        var(--surface-0);
}

.login-panel {
    width: 100%;
    max-width: 400px;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 4px);
    padding: 2rem 2rem 2.25rem;
    box-shadow: var(--shadow-md);
}

.login-brand {
    text-align: center;
    margin-bottom: 1.75rem;
}

.login-mark,
.app-mark {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: linear-gradient(145deg, var(--accent), #0f766e);
    margin: 0 auto 1rem;
    box-shadow: 0 4px 14px rgba(13, 148, 136, 0.35);
}

.login-brand h1 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.login-brand p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.field-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.field-input {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: 0.95rem;
    color: var(--text);
    background: var(--surface-1);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.field-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-muted);
}

.field-input--muted {
    background: var(--surface-2);
    color: var(--text-muted);
}

.field-error {
    font-size: 0.85rem;
    color: var(--danger);
    min-height: 1.25rem;
    margin-top: 0.35rem;
}

.optional {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-muted);
}

/* —— Buttons —— */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}

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

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

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-outline {
    background: var(--surface-1);
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn-outline:hover:not(:disabled) {
    border-color: var(--border-strong);
    background: var(--surface-2);
}

.btn-outline--danger {
    color: var(--danger);
    border-color: rgba(220, 38, 38, 0.35);
}

.btn-outline--danger:hover:not(:disabled) {
    background: var(--danger-muted);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
    color: var(--text);
    background: var(--surface-2);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-block {
    width: 100%;
    margin-top: 0.75rem;
    padding: 0.65rem;
}

.btn-icon {
    padding: 0.35rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
}

.btn-icon:hover:not(:disabled) {
    background: var(--accent-muted);
}

.btn-icon--danger {
    color: var(--danger);
}

.btn-icon--danger:hover:not(:disabled) {
    background: var(--danger-muted);
}

/* —— App shell —— */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1.25rem;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.app-header__brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.app-mark {
    margin: 0;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.app-header__title {
    display: block;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.app-header__meta {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.app-header__actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.pill--ok {
    background: var(--success-muted);
    color: var(--success);
}

.pill__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.35;
    }
}

.app-body {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 1.25rem 1.25rem 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* —— KPI —— */
.kpi-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

@media (max-width: 720px) {
    .kpi-strip {
        grid-template-columns: 1fr;
    }
}

.kpi {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.kpi__label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.kpi__value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

/* —— Cards —— */
.card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card--last {
    margin-bottom: 0;
}

.card__head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface-1) 100%);
}

.card__title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.card__desc {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
    max-width: 36rem;
}

.card__head-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.search-field {
    position: relative;
    display: flex;
    align-items: center;
}

.search-field__icon {
    position: absolute;
    left: 0.65rem;
    color: var(--text-muted);
    pointer-events: none;
}

.search-field__input {
    width: 220px;
    max-width: 100%;
    padding: 0.45rem 0.65rem 0.45rem 2rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: 0.875rem;
    background: var(--surface-1);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.search-field__input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-muted);
}

@media (min-width: 900px) {
    .search-field__input {
        width: 260px;
    }
}

/* —— Toolbar —— */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem 1.25rem;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}

.toolbar__meta {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.toolbar__btns {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

/* —— Table —— */
.table-panel {
    display: flex;
    flex-direction: column;
}

.table-scroll {
    max-height: min(58vh, 520px);
    overflow: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    text-align: left;
    padding: 0.55rem 0.85rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 0 var(--border);
}

.data-table tbody td {
    padding: 0.45rem 0.85rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tbody tr:hover td {
    background: rgba(13, 148, 136, 0.03);
}

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

.col-actions {
    width: 5.5rem;
    text-align: right;
}

.country-cell {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.country-cell .flag {
    font-size: 1.25rem;
    line-height: 1;
    width: 1.75rem;
    text-align: center;
}

.country-cell .name {
    font-weight: 600;
    color: var(--text);
}

.country-cell .code {
    font-size: 0.7rem;
    font-family: var(--mono);
    color: var(--text-muted);
}

.reward-input {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

.reward-input .currency {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.reward-input input {
    width: 4.5rem;
    padding: 0.3rem 0.4rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: var(--mono);
    font-size: 0.8125rem;
    text-align: right;
    background: var(--surface-2);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.reward-input input:hover {
    border-color: var(--border);
}

.reward-input input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--surface-1);
    box-shadow: 0 0 0 2px var(--accent-muted);
}

.reward-input input.saved {
    border-color: var(--success);
    background: var(--success-muted);
}

/* Toggle */
.toggle {
    position: relative;
    width: 36px;
    height: 20px;
    display: inline-block;
    cursor: pointer;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle .slider {
    position: absolute;
    inset: 0;
    background: var(--border-strong);
    border-radius: 999px;
    transition: background 0.15s;
}

.toggle .slider::before {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
    transition: transform 0.15s;
}

.toggle input:checked + .slider {
    background: var(--success);
}

.toggle input:checked + .slider::before {
    transform: translateX(16px);
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-active {
    background: var(--success-muted);
    color: var(--success);
}

.badge-inactive {
    background: var(--surface-2);
    color: var(--text-muted);
}

.row-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.15rem;
}

/* Pagination */
.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem 1.25rem;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
}

.pagination__info {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.pagination__controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.pagination__size {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.select-inline {
    font: inherit;
    font-size: 0.8125rem;
    padding: 0.25rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-1);
    color: var(--text);
}

.table-footnote {
    padding: 0.5rem 1.25rem 0.85rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    border-top: 1px solid var(--border);
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.55s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Settings */
.settings-grid {
    display: grid;
    gap: 1rem;
    padding: 1.25rem;
}

@media (min-width: 768px) {
    .settings-grid {
        grid-template-columns: 1fr 1fr;
        align-items: start;
    }
}

.settings-copy h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.35rem;
}

.settings-copy p {
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.input-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.input-row .field-input {
    flex: 1;
    min-width: 160px;
}

.settings-status {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.inline-code {
    font-family: var(--mono);
    font-size: 0.8em;
    background: var(--surface-2);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
}

/* Modals */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 20, 0.45);
    backdrop-filter: blur(2px);
}

.modal__dialog {
    position: relative;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.35rem 1.35rem 1.15rem;
    box-shadow: var(--shadow-md);
}

.modal__title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.35rem;
}

.modal__text {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    line-height: 1.45;
}

.modal__dialog .field-label {
    margin-top: 0.75rem;
}

.modal__dialog .field-label:first-of-type {
    margin-top: 0;
}

.modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.25rem;
    padding-top: 0.25rem;
}

/* Toast */
.toast-container {
    position: fixed;
    top: 4.5rem;
    right: 1rem;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-width: min(360px, calc(100vw - 2rem));
}

.toast {
    padding: 0.65rem 1rem;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    box-shadow: var(--shadow-md);
    animation: toastIn 0.2s ease;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--danger);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(0.5rem);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}
