:root {
    --bg-deep: #080c12;
    --bg-mid: #0e1520;
    --surface: rgba(22, 32, 48, 0.72);
    --surface-solid: #141d2c;
    --surface-elevated: rgba(28, 40, 58, 0.88);
    --border: rgba(100, 130, 180, 0.22);
    --border-strong: rgba(120, 160, 220, 0.35);
    --text: #eef2f9;
    --muted: #8fa3bc;
    --accent: #5b9cfa;
    --accent-dim: rgba(91, 156, 250, 0.15);
    --accent-hover: #7eb0fc;
    --accent-glow: rgba(91, 156, 250, 0.35);
    --warn: #e8b84a;
    --danger: #f87171;
    --success: #4ade80;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow-lg: 0 28px 80px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 12px 40px rgba(0, 0, 0, 0.35);
    --shadow-toast: 0 10px 40px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    --font: "SF Pro Text", "Segoe UI", system-ui, -apple-system, sans-serif;
    font-family: var(--font);
}

::selection {
    background: rgba(91, 156, 250, 0.35);
    color: #fff;
}

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

html {
    -webkit-font-smoothing: antialiased;
}

body {
    margin: 0;
    color: var(--text);
    min-height: 100vh;
    line-height: 1.55;
    background: var(--bg-deep);
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-hover);
}

.muted {
    color: var(--muted);
    font-size: 0.9rem;
}

/* —— Auth —— */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.25rem;
    position: relative;
    overflow: hidden;
    min-height: 100vh;
}

.auth-body::before {
    content: "";
    position: absolute;
    inset: -40%;
    background:
        radial-gradient(ellipse 50% 40% at 20% 20%, rgba(91, 156, 250, 0.18), transparent 55%),
        radial-gradient(ellipse 45% 35% at 85% 75%, rgba(139, 92, 246, 0.12), transparent 50%),
        linear-gradient(165deg, var(--bg-deep) 0%, var(--bg-mid) 100%);
    z-index: 0;
}

.auth-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.25rem 2rem 2rem;
    box-shadow: var(--shadow-lg);
    animation: auth-card-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes auth-card-in {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 1.5rem;
}

.auth-logo {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent) 0%, #8b5cf6 100%);
    box-shadow: 0 8px 24px var(--accent-glow);
    overflow: hidden;
}

.auth-logo::after {
    content: "";
    position: absolute;
    inset: -50%;
    background: linear-gradient(
        125deg,
        transparent 40%,
        rgba(255, 255, 255, 0.2) 48%,
        transparent 56%
    );
    animation: logo-shine 6s ease-in-out infinite;
}

@keyframes logo-shine {
    0%,
    70% {
        transform: translateX(-100%) rotate(12deg);
    }
    85%,
    100% {
        transform: translateX(100%) rotate(12deg);
    }
}

.auth-card h1 {
    margin: 0;
    font-size: 1.45rem;
    font-weight: 650;
    letter-spacing: -0.02em;
}

.auth-card .muted {
    margin: 0.35rem 0 0;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    margin-top: 1.5rem;
}

.stack label span {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: 0.4rem;
}

textarea {
    width: 100%;
    min-height: 5.5rem;
    padding: 0.72rem 0.9rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: rgba(8, 12, 20, 0.55);
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    line-height: 1.45;
    resize: vertical;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

input[type="text"],
input[type="password"],
select {
    width: 100%;
    padding: 0.72rem 0.9rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: rgba(8, 12, 20, 0.55);
    color: var(--text);
    font-size: 1rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238fa3bc' d='M3 4.5L6 8l3-3.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.25rem;
}

/* —— Buttons —— */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.58rem 1.1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: rgba(36, 52, 78, 0.65);
    color: var(--text);
    font-size: 0.92rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.btn:hover {
    background: rgba(48, 68, 100, 0.85);
    border-color: var(--border-strong);
}

.btn:active {
    transform: translateY(1px);
}

.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

a.btn:focus-visible {
    outline-offset: 2px;
}

.btn-accent,
.btn.primary {
    background: linear-gradient(135deg, #4f8fef 0%, #5b9cfa 50%, #6b8cff 100%);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 6px 20px rgba(91, 156, 250, 0.35);
}

.btn-accent:hover,
.btn.primary:hover {
    background: linear-gradient(135deg, #6ba3fc 0%, #7eb0fc 100%);
    border-color: transparent;
}

.btn-outline {
    background: transparent;
    border-color: var(--border-strong);
}

.btn-outline:hover {
    background: rgba(91, 156, 250, 0.08);
}

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

.btn-ghost:hover,
.btn.ghost:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
}

.btn.full {
    width: 100%;
}

.btn-sm {
    padding: 0.42rem 0.75rem;
    font-size: 0.82rem;
    white-space: nowrap;
}

.btn-icon {
    font-size: 1.15rem;
    font-weight: 300;
    line-height: 1;
    opacity: 0.95;
}

.btn-icon-sheet {
    width: 14px;
    height: 14px;
    border: 1.5px solid currentColor;
    border-radius: 2px;
    opacity: 0.85;
}

/* —— Alerts —— */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin: 1rem 0 0;
    border: 1px solid transparent;
}

.alert-error {
    background: rgba(248, 113, 113, 0.1);
    border-color: rgba(248, 113, 113, 0.35);
    color: #fecaca;
}

.alert-success {
    background: rgba(74, 222, 128, 0.1);
    border-color: rgba(74, 222, 128, 0.3);
    color: #bbf7d0;
}

.flash {
    margin: 0 0 1.25rem;
    transition: opacity 0.4s ease, transform 0.4s ease, margin 0.35s ease, padding 0.35s ease;
}

.flash-toast {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1.15rem;
    border-radius: 12px;
    box-shadow: var(--shadow-toast);
    font-weight: 500;
    letter-spacing: 0.01em;
}

.flash-toast::before {
    content: "";
    flex-shrink: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    box-shadow: 0 0 14px currentColor;
}

.flash-toast.alert-success::before {
    background: var(--success);
    color: var(--success);
}

.flash-toast.alert-error::before {
    background: var(--danger);
    color: var(--danger);
}

.flash.is-dismissed {
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    max-height: 0;
    overflow: hidden;
    border-width: 0;
}

/* —— Admin layout —— */
.admin-body {
    position: relative;
    min-height: 100vh;
}

.admin-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 80% 50% at 10% -10%, rgba(91, 156, 250, 0.2), transparent 50%),
        radial-gradient(ellipse 60% 45% at 100% 0%, rgba(139, 92, 246, 0.12), transparent 45%),
        radial-gradient(ellipse 50% 40% at 50% 100%, rgba(34, 197, 94, 0.06), transparent 45%),
        linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-mid) 55%, var(--bg-deep) 100%);
}

.admin-bg::after {
    content: "";
    position: absolute;
    inset: 0;
    opacity: 0.35;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
}

.shell {
    position: relative;
    z-index: 1;
    max-width: 1180px;
    margin: 0 auto;
    padding: 1.75rem 1.35rem 3.5rem;
}

.admin-header {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.25rem;
    margin-bottom: 1.75rem;
    padding: 1.35rem 1.5rem;
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    animation: header-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.admin-header::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), #a78bfa, transparent);
    opacity: 0.85;
}

.admin-header::after {
    content: "";
    position: absolute;
    right: -20%;
    top: -60%;
    width: 45%;
    height: 160%;
    background: radial-gradient(ellipse, rgba(91, 156, 250, 0.08), transparent 70%);
    pointer-events: none;
}

@keyframes header-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.admin-header-main {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 1.1rem;
    align-items: flex-start;
}

.brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    flex-shrink: 0;
    background: linear-gradient(140deg, var(--accent) 0%, #7c6cf0 100%);
    box-shadow: 0 10px 28px var(--accent-glow);
}

.admin-kicker {
    margin: 0;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
}

.admin-title {
    margin: 0.2rem 0 0;
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.admin-sub {
    margin: 0.4rem 0 0;
    font-size: 0.9rem;
}

.admin-user {
    color: var(--text);
    font-weight: 600;
}

.toolbar {
    position: relative;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    align-items: center;
}

/* —— Stats —— */
.stat-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.85rem;
    margin-bottom: 1.35rem;
}

@media (max-width: 900px) {
    .stat-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

.stat-card {
    position: relative;
    padding: 1rem 1.15rem 1rem 1.05rem;
    border-radius: var(--radius-sm);
    background: rgba(20, 29, 44, 0.65);
    border: 1px solid var(--border);
    border-left: 3px solid rgba(100, 130, 180, 0.35);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    animation: stat-in 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.stat-card:nth-child(1) {
    animation-delay: 0.04s;
}
.stat-card:nth-child(2) {
    animation-delay: 0.08s;
}
.stat-card:nth-child(3) {
    animation-delay: 0.12s;
}
.stat-card:nth-child(4) {
    animation-delay: 0.16s;
}

@keyframes stat-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stat-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
}

.stat-card--accent {
    border-left-color: var(--accent);
}

.stat-card--warn {
    border-left-color: var(--warn);
}

.stat-card--danger {
    border-left-color: var(--danger);
}

.stat-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.stat-value {
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.stat-card--accent .stat-value {
    color: var(--accent);
}

.stat-card--warn .stat-value {
    color: var(--warn);
}

.stat-card--danger .stat-value {
    color: var(--danger);
}

/* —— Panels —— */
.panel {
    position: relative;
    background: var(--surface);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    margin-bottom: 1.1rem;
    animation: panel-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes panel-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(91, 156, 250, 0.25), transparent);
    pointer-events: none;
}

.search-panel {
    padding: 0;
    animation-delay: 0.06s;
}

.panel-head {
    padding: 1.15rem 1.35rem 0.85rem;
    border-bottom: 1px solid var(--border);
}

.panel-head--table {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.panel-title::before {
    content: "";
    width: 3px;
    height: 1.05em;
    border-radius: 3px;
    background: linear-gradient(180deg, var(--accent), #8b5cf6);
    flex-shrink: 0;
    opacity: 0.95;
}

.panel-desc {
    margin: 0.25rem 0 0;
    font-size: 0.85rem;
}

.search-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
    padding: 1rem 1.35rem 1.25rem;
}

.search-field {
    position: relative;
    flex: 1 1 240px;
    min-width: 200px;
}

.search-field input {
    width: 100%;
    padding-left: 2.65rem;
    transition: border-color 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.search-field input:hover {
    border-color: rgba(120, 160, 220, 0.4);
    background: rgba(10, 14, 22, 0.65);
}

.search-icon {
    position: absolute;
    left: 0.95rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border: 2px solid var(--muted);
    border-radius: 50%;
    opacity: 0.55;
}

.search-icon::after {
    content: "";
    position: absolute;
    width: 7px;
    height: 2px;
    background: var(--muted);
    border-radius: 1px;
    right: -5px;
    bottom: -1px;
    transform: rotate(42deg);
    opacity: 0.85;
}

.table-panel {
    padding: 0;
    animation-delay: 0.11s;
}

.table-scroll {
    overflow-x: auto;
    margin: 0;
    scrollbar-color: rgba(91, 156, 250, 0.35) rgba(0, 0, 0, 0.2);
    scrollbar-width: thin;
}

.table-scroll::-webkit-scrollbar {
    height: 8px;
}

.table-scroll::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.table-scroll::-webkit-scrollbar-thumb {
    background: linear-gradient(90deg, rgba(91, 156, 250, 0.4), rgba(139, 92, 246, 0.35));
    border-radius: 4px;
}

.table-scroll::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(90deg, rgba(91, 156, 250, 0.55), rgba(139, 92, 246, 0.5));
}

.data-table {
    width: 100%;
    min-width: 72rem;
    table-layout: auto;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 0.85rem 1.25rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    overflow: visible;
}

.data-table .col-id {
    width: 3.5rem;
}

.data-table .col-name {
    min-width: 6.5rem;
}

.data-table .col-no {
    min-width: 5.5rem;
}

.data-table .col-code {
    min-width: 11rem;
}

.data-table .col-status {
    min-width: 5.5rem;
}

.data-table .col-remarks {
    min-width: 7rem;
}

.data-table .col-action {
    min-width: 9.5rem;
}

.data-table .col-time {
    min-width: 11rem;
}

.data-table td.col-name,
.data-table td.col-no,
.data-table td.col-status,
.data-table td.col-action {
    white-space: nowrap;
}

.data-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: rgba(12, 18, 28, 0.95);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    white-space: nowrap;
}

.data-table tbody tr {
    transition: background 0.12s ease;
}

.data-table tbody tr:hover {
    background: rgba(91, 156, 250, 0.07);
}

.data-table tbody tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.12);
}

.data-table tbody tr:nth-child(even):hover {
    background: rgba(91, 156, 250, 0.08);
}

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

.data-table td:first-child {
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    font-weight: 500;
}

.cell-remarks {
    max-width: 14rem;
    font-size: 0.86rem;
    color: var(--muted);
    word-break: break-word;
}

.device-code {
    display: inline-block;
    font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, monospace;
    font-size: 0.84rem;
    padding: 0.28rem 0.55rem;
    border-radius: 8px;
    background: rgba(91, 156, 250, 0.12);
    border: 1px solid rgba(91, 156, 250, 0.25);
    color: #b8d7ff;
    max-width: 100%;
    word-break: break-all;
}

.device-code--block {
    display: block;
    width: 100%;
    padding: 0.55rem 0.75rem;
    font-size: 0.88rem;
}

.readonly-field {
    margin-bottom: 0.25rem;
}

.readonly-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: 0.4rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.22rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
    flex-shrink: 0;
}

.data-table .badge {
    max-width: none;
    overflow: visible;
    text-overflow: clip;
}

.row-actions {
    display: inline-flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.45rem;
}

.row-actions .inline-form {
    display: inline-flex;
    margin: 0;
}

.data-table td.col-action .btn {
    display: inline-flex;
    white-space: nowrap;
}

.btn-danger {
    background: rgba(248, 113, 113, 0.15);
    border-color: rgba(248, 113, 113, 0.45);
    color: #fecaca;
}

.btn-danger:hover {
    background: rgba(248, 113, 113, 0.28);
    border-color: rgba(248, 113, 113, 0.6);
    color: #fff;
}

.badge-bound {
    background: rgba(91, 156, 250, 0.2);
    color: #b8d9ff;
    border: 1px solid rgba(91, 156, 250, 0.35);
}

.badge-unbound {
    background: rgba(232, 184, 74, 0.15);
    color: #fde68a;
    border: 1px solid rgba(232, 184, 74, 0.35);
}

.badge-disabled {
    background: rgba(248, 113, 113, 0.15);
    color: #fecaca;
    border: 1px solid rgba(248, 113, 113, 0.35);
}

/* —— Empty —— */
.empty {
    padding: 3rem 1.5rem;
    text-align: center;
}

.empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1.1rem;
    border-radius: 18px;
    border: 1px solid var(--border);
    background:
        linear-gradient(rgba(91, 156, 250, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(91, 156, 250, 0.06) 1px, transparent 1px);
    background-size: 10px 10px;
    background-color: rgba(12, 18, 28, 0.5);
    box-shadow: inset 0 0 24px rgba(91, 156, 250, 0.06);
    opacity: 0.85;
}

.empty-title {
    margin: 0 0 0.35rem;
    font-size: 1.05rem;
    font-weight: 600;
}

/* —— Modal —— */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(4, 8, 14, 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 100;
}

.modal-backdrop.open {
    display: flex;
    animation: backdrop-in 0.2s ease-out both;
}

@keyframes backdrop-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal {
    width: 100%;
    max-width: 440px;
    position: relative;
    background: linear-gradient(165deg, rgba(26, 36, 52, 0.98) 0%, var(--surface-solid) 100%);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 0;
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    animation: modal-in 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.modal::before {
    content: "";
    position: absolute;
    left: 1.25rem;
    right: 1.25rem;
    top: 0;
    height: 2px;
    border-radius: 0 0 4px 4px;
    background: linear-gradient(90deg, transparent, var(--accent), #a78bfa, transparent);
    opacity: 0.75;
    pointer-events: none;
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-head {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.35rem;
    border-bottom: 1px solid var(--border);
}

.modal-head h2 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 650;
    letter-spacing: -0.02em;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--muted);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

.modal-close:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.modal-lead {
    margin: 0;
    padding: 1rem 1.35rem 0;
    font-size: 0.88rem;
    line-height: 1.5;
}

.modal-form {
    padding: 1rem 1.35rem 1.35rem;
    margin-top: 0;
}

.modal-actions {
    display: flex;
    gap: 0.55rem;
    justify-content: flex-end;
    margin-top: 0.25rem;
}

@media (max-width: 640px) {
    .admin-header {
        padding: 1.1rem;
    }

    .toolbar {
        width: 100%;
    }

    .toolbar .btn {
        flex: 1 1 auto;
        justify-content: center;
    }

    .data-table th:nth-child(8),
    .data-table td:nth-child(8),
    .data-table th:nth-child(9),
    .data-table td:nth-child(9) {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .auth-logo::after {
        animation: none;
        opacity: 0;
    }
}
