@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@500;600;700;800&display=swap");

:root {
    --bg-main: #0a0f1e;
    --bg-card: #0d1428;
    --bg-card-strong: #101a32;
    --bg-soft: rgba(255, 255, 255, 0.02);
    --bg-soft-hover: rgba(255, 255, 255, 0.045);
    --border-subtle: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.14);
    --text-primary: rgba(255, 255, 255, 0.96);
    --text-secondary: rgba(255, 255, 255, 0.42);
    --text-tertiary: rgba(255, 255, 255, 0.3);
    --accent-blue: #4a90d9;
    --accent-blue-strong: #2d7fd6;
    --success: #34d399;
    --warning: #f59e0b;
    --danger: #f87171;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 22px;
    --shadow-card: 0 20px 55px rgba(0, 0, 0, 0.34);
}

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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    font-size: 16px;
}

body {
    min-height: 100vh;
    padding: 22px;
    background:
        radial-gradient(1100px 640px at 0% -10%, rgba(74, 144, 217, 0.16), transparent 60%),
        radial-gradient(900px 500px at 105% 0%, rgba(52, 211, 153, 0.08), transparent 55%),
        linear-gradient(160deg, #070b16, var(--bg-main) 38%, #0b1224);
    color: var(--text-primary);
    font-family: "Manrope", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.4;
}

body::before,
body::after {
    content: "";
    position: fixed;
    z-index: 0;
    pointer-events: none;
}

body::before {
    inset: auto 6% 8% auto;
    width: 240px;
    height: 240px;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(74, 144, 217, 0.22), transparent 72%);
}

body::after {
    inset: 8% auto auto 4%;
    width: 180px;
    height: 180px;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(148, 163, 184, 0.12), transparent 72%);
}

.container {
    width: min(1480px, 100%);
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

body:not(.webhook-page) .container {
    display: grid;
    grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
    gap: 20px 24px;
    align-items: start;
}

header {
    margin-bottom: 18px;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-subtle);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01)),
        var(--bg-card);
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(6px);
}

body:not(.webhook-page) header {
    grid-column: 1;
    grid-row: 1 / span 4;
    padding: 20px;
    position: sticky;
    top: 22px;
    margin-bottom: 0;
}

.webhook-page header {
    padding: 18px 20px;
}

header h1 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.015em;
    color: var(--text-primary);
}

header h1 i {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #eff6ff;
    background: linear-gradient(165deg, rgba(74, 144, 217, 0.95), rgba(60, 127, 197, 0.95));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

header p {
    margin-top: 6px;
    font-size: 0.76rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.muted-note {
    margin-top: 10px;
    font-size: 0.73rem;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}

.header-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 16px;
}

body:not(.webhook-page) .header-actions {
    align-items: stretch;
    flex-direction: column;
}

body:not(.webhook-page) .header-actions .btn {
    width: 100%;
    justify-content: flex-start;
}

.notice-area {
    grid-column: 2;
    display: grid;
    gap: 10px;
}

.notice-area .message {
    margin-top: 0;
}

.main-content {
    display: grid;
    gap: 20px;
    margin-bottom: 2px;
}

body:not(.webhook-page) .main-content {
    grid-column: 2;
    grid-template-columns: repeat(12, minmax(0, 1fr));
}

body:not(.webhook-page) .main-content > .card:nth-child(1),
body:not(.webhook-page) .main-content > .card:nth-child(2) {
    grid-column: span 6;
}

body:not(.webhook-page) .main-content > .card:nth-child(3) {
    grid-column: span 12;
}

body:not(.webhook-page) .main-content > .virtual-gate-card {
    grid-column: span 12;
}

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

footer {
    grid-column: 2;
    margin-top: 2px;
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    background: var(--bg-soft);
    text-align: center;
}

footer p {
    margin-top: 10px;
    font-size: 0.78rem;
    letter-spacing: 0.01em;
    color: var(--text-secondary);
}

.card {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 30%),
        var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 20px;
    box-shadow: var(--shadow-card);
}

.card h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.9rem;
    letter-spacing: 0.075em;
    text-transform: uppercase;
    color: var(--text-primary);
}

.card h2 i {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #cae4ff;
    background: rgba(74, 144, 217, 0.2);
    border: 1px solid rgba(74, 144, 217, 0.42);
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    padding: 11px 12px;
    font-size: 0.9rem;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-tertiary);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: rgba(74, 144, 217, 0.7);
    background: rgba(74, 144, 217, 0.08);
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.16);
}

.btn {
    border: 1px solid var(--border-subtle);
    background: var(--bg-soft);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.81rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-right: 0;
}

.btn:hover {
    transform: translateY(-1px);
    background: var(--bg-soft-hover);
    border-color: var(--border-strong);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    color: #ecf5ff;
    border-color: rgba(74, 144, 217, 0.55);
    background: linear-gradient(165deg, rgba(74, 144, 217, 0.9), rgba(45, 127, 214, 0.9));
}

.btn-primary:hover {
    background: linear-gradient(165deg, rgba(86, 153, 223, 0.95), rgba(56, 136, 222, 0.95));
}

.btn-success {
    color: #f0fdf4;
    border-color: rgba(52, 211, 153, 0.6);
    background: linear-gradient(160deg, rgba(16, 185, 129, 0.92), rgba(5, 150, 105, 0.9));
}

.btn-success:hover {
    background: linear-gradient(160deg, rgba(23, 200, 139, 0.95), rgba(7, 164, 115, 0.93));
}

.btn-warning {
    color: #fefce8;
    border-color: rgba(245, 158, 11, 0.6);
    background: linear-gradient(160deg, rgba(217, 119, 6, 0.92), rgba(180, 83, 9, 0.9));
}

.btn-warning:hover {
    background: linear-gradient(160deg, rgba(230, 135, 22, 0.95), rgba(196, 96, 18, 0.93));
}

.btn-danger {
    color: #fff1f2;
    border-color: rgba(248, 113, 113, 0.6);
    background: linear-gradient(160deg, rgba(239, 68, 68, 0.92), rgba(220, 38, 38, 0.9));
}

.btn-danger:hover {
    background: linear-gradient(160deg, rgba(247, 83, 83, 0.95), rgba(230, 53, 53, 0.93));
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.16);
    color: rgba(255, 255, 255, 0.86);
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.virtual-gate-layout {
    display: grid;
    gap: 18px;
}

.virtual-scan-panel,
.virtual-table-block {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.02);
    padding: 14px;
}

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

.panel-heading h3 {
    font-size: 0.8rem;
    letter-spacing: 0.075em;
    text-transform: uppercase;
    color: var(--text-primary);
}

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

.virtual-scan-actions .btn {
    min-height: 42px;
    justify-content: flex-start;
    min-width: 0;
    white-space: normal;
    line-height: 1.15;
}

.virtual-scan-actions .btn:disabled {
    cursor: wait;
    opacity: 0.65;
    transform: none;
}

.virtual-status-success {
    color: #bbf7d0;
}

.virtual-status-warning {
    color: #fde68a;
}

.virtual-status-error {
    color: #fecdd3;
}

.message {
    display: none;
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 0.8rem;
    letter-spacing: 0.02em;
}

.message.success {
    display: block;
    color: #d1fae5;
    background: rgba(16, 185, 129, 0.14);
    border-color: rgba(16, 185, 129, 0.35);
}

.message.error {
    display: block;
    color: #ffe4e6;
    background: rgba(239, 68, 68, 0.14);
    border-color: rgba(239, 68, 68, 0.35);
}

.message.warning {
    display: block;
    color: #fef3c7;
    background: rgba(245, 158, 11, 0.14);
    border-color: rgba(245, 158, 11, 0.36);
}

.message.info {
    display: block;
    color: #dbeafe;
    background: rgba(74, 144, 217, 0.14);
    border-color: rgba(74, 144, 217, 0.36);
}

.sessions-list,
.facilities-list,
.accounts-list {
    max-height: 430px;
    overflow: auto;
    padding-right: 2px;
}

.facility-item,
.session-item {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.02);
    padding: 14px 14px 12px;
    margin-bottom: 10px;
}

.facility-item {
    border-left: 3px solid rgba(74, 144, 217, 0.82);
}

.facility-item h3 {
    margin-bottom: 8px;
    font-size: 0.94rem;
    font-weight: 700;
    color: var(--text-primary);
}

.facility-item p {
    font-size: 0.82rem;
    margin-bottom: 4px;
    color: var(--text-secondary);
}

.session-item {
    border-left: 3px solid rgba(52, 211, 153, 0.85);
}

.session-item.completed {
    border-left-color: rgba(74, 144, 217, 0.84);
}

.session-item h3 {
    font-size: 0.88rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 10px;
    color: rgba(255, 255, 255, 0.92);
}

.session-details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px 10px;
    font-size: 0.83rem;
}

.session-details div {
    color: var(--text-secondary);
}

.session-details strong {
    color: var(--text-primary);
    font-weight: 600;
}

.cost {
    margin-top: 12px;
    font-size: 1.06rem;
    font-weight: 800;
    color: #93c5fd;
    letter-spacing: 0.01em;
}

.empty-state {
    text-align: center;
    color: var(--text-tertiary);
    padding: 22px;
    font-size: 0.83rem;
}

.tabs {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px;
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.02);
    margin-bottom: 14px;
}

.tab {
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 9px;
    padding: 8px 12px;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.tab:hover {
    color: rgba(255, 255, 255, 0.84);
}

.tab.active {
    color: #e8f2fe;
    border-color: rgba(74, 144, 217, 0.44);
    background: rgba(74, 144, 217, 0.2);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 8px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.02);
}

.virtual-gate-card {
    min-width: 0;
}

.virtual-table-block {
    min-width: 0;
    overflow: hidden;
}

.virtual-gate-card table {
    table-layout: fixed;
}

.virtual-gate-card th,
.virtual-gate-card td {
    padding: 8px 9px;
    font-size: 0.75rem;
    vertical-align: middle;
    overflow-wrap: anywhere;
}

.virtual-gate-card th {
    font-size: 0.62rem;
    letter-spacing: 0.07em;
}

.table-time {
    width: 11%;
}

.table-epc {
    width: 18%;
    font-family: "Cascadia Code", "Consolas", "Menlo", "Monaco", monospace;
    font-size: 0.68rem;
    line-height: 1.25;
}

.table-reader {
    width: 11%;
}

.table-signal {
    width: 9%;
}

.table-reason {
    width: 16%;
}

thead {
    background: rgba(255, 255, 255, 0.02);
}

th,
td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.81rem;
}

th {
    font-size: 0.67rem;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 700;
}

td {
    color: rgba(255, 255, 255, 0.88);
}

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

tbody tr:hover {
    background: rgba(255, 255, 255, 0.04);
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid transparent;
    padding: 3px 8px;
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 0.055em;
    text-transform: uppercase;
}

.badge-success {
    color: #d1fae5;
    background: rgba(16, 185, 129, 0.16);
    border-color: rgba(16, 185, 129, 0.36);
}

.badge-warning {
    color: #fde68a;
    background: rgba(245, 158, 11, 0.16);
    border-color: rgba(245, 158, 11, 0.35);
}

.badge-danger {
    color: #fecdd3;
    background: rgba(239, 68, 68, 0.16);
    border-color: rgba(239, 68, 68, 0.35);
}

.badge-info {
    color: #bfdbfe;
    background: rgba(74, 144, 217, 0.18);
    border-color: rgba(74, 144, 217, 0.34);
}

.badge-secondary {
    color: rgba(255, 255, 255, 0.72);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.18);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(5, 10, 24, 0.78);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 14px;
}

.modal-backdrop.active {
    display: flex;
}

.modal {
    width: min(640px, 100%);
    max-height: min(92vh, 900px);
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-subtle);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 36%),
        var(--bg-card-strong);
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55);
    overflow: hidden;
}

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

.modal-header h2 {
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-primary);
}

.modal-close {
    border: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 1.2rem;
    cursor: pointer;
}

.modal-close:hover {
    color: var(--text-primary);
    border-color: rgba(74, 144, 217, 0.4);
    background: rgba(74, 144, 217, 0.14);
}

.modal-body {
    overflow: auto;
    padding: 16px 18px;
    flex: 1 1 auto;
}

.modal-body .card {
    box-shadow: none;
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.08);
    padding: 16px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 18px 16px;
    border-top: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.015);
}

.auth-modal-backdrop {
    z-index: 2000;
}

.auth-modal-backdrop .modal {
    width: min(460px, 100%);
}

#loginError {
    margin-top: 8px;
}

.switch {
    position: relative;
    width: 52px;
    height: 30px;
    display: inline-block;
    flex-shrink: 0;
}

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

.slider {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    border: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: 0.2s ease;
}

.slider::before {
    content: "";
    position: absolute;
    width: 22px;
    height: 22px;
    left: 3px;
    top: 3px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.88);
    transition: 0.2s ease;
}

input:checked + .slider {
    border-color: rgba(74, 144, 217, 0.5);
    background: rgba(74, 144, 217, 0.35);
}

input:checked + .slider::before {
    transform: translateX(22px);
    background: #ffffff;
}

input:focus + .slider {
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.22);
}

.auto-refresh-switch {
    margin-left: 4px;
}

.toggle-label {
    color: var(--text-secondary);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.payload-json {
    font-family: "Cascadia Code", "Consolas", "Menlo", "Monaco", monospace;
    font-size: 0.82rem;
    line-height: 1.45;
}

.muted-inline {
    color: var(--text-secondary);
}

.webhook-page footer {
    margin-top: 14px;
}

.webhook-page .card h2 {
    margin-bottom: 14px;
    padding-bottom: 10px;
}

.webhook-page .form-group textarea {
    min-height: 340px;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 999px;
}

::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.45);
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.7);
}

@media (max-width: 1220px) {
    body:not(.webhook-page) .container {
        grid-template-columns: minmax(220px, 250px) minmax(0, 1fr);
    }

    body:not(.webhook-page) .main-content > .card:nth-child(1),
    body:not(.webhook-page) .main-content > .card:nth-child(2) {
        grid-column: span 12;
    }

    .webhook-page .main-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 980px) {
    body {
        padding: 14px;
    }

    body:not(.webhook-page) .container {
        grid-template-columns: 1fr;
    }

    body:not(.webhook-page) header {
        position: static;
        top: auto;
        grid-column: 1;
        grid-row: auto;
    }

    body:not(.webhook-page) .header-actions {
        flex-direction: row;
        align-items: center;
    }

    body:not(.webhook-page) .header-actions .btn {
        width: auto;
    }

    .notice-area,
    body:not(.webhook-page) .main-content,
    footer {
        grid-column: 1;
    }

    body:not(.webhook-page) .main-content {
        grid-template-columns: 1fr;
    }

    body:not(.webhook-page) .main-content > .card:nth-child(3) {
        grid-column: span 1;
    }

    .session-details {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .header-actions {
        gap: 8px;
    }

    .btn {
        width: 100%;
    }

    .button-group {
        flex-direction: column;
    }

    .tabs {
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
    }

    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .modal {
        max-height: 95vh;
    }

    .modal-footer {
        flex-wrap: wrap;
    }
}
