/* Design tokens
############################################################## */

:root {
    --content-max-width: 1440px;

    --primary-25: #f0f6fa;
    --primary-50: #c3dcea;
    --primary-100: #a4cbdf;
    --primary-200: #86b9d5;
    --primary-300: #64a6c9;
    --primary-400: #4a96bf;
    --primary-500: #3a80a6;
    --primary-600: #306988;
    --primary-700: #25526a;
    --primary-800: #1b3a4b;
    --primary-900: #10232d;
    --primary-950: #050c0f;

    --grey-25: #e8eaed;
    --grey-50: #d0d5dc;
    --grey-100: #b9c1ca;
    --grey-200: #a2acb9;
    --grey-300: #8b97a7;
    --grey-400: #738296;
    --grey-500: #606e80;
    --grey-600: #4f5a69;
    --grey-700: #3d4651;
    --grey-800: #2b3139;
    --grey-900: #1a1e23;
    --grey-950: #090a0c;

    --success-25: #d9fcef;
    --success-500: #0ecb81;
    --success-700: #098656;
    --success-950: #01130c;
    --failure-25: #fdd8dd;
    --failure-200: #f86377;
    --failure-700: #b91f34;

    --canvas: var(--primary-950);
    --surface: var(--grey-900);
    --surface-raised: var(--grey-800);
    --surface-soft: #11181d;
    --line: rgba(208, 213, 220, 0.14);
    --line-strong: rgba(208, 213, 220, 0.24);
    --text: var(--grey-25);
    --text-muted: var(--grey-200);
    --text-subtle: var(--grey-400);

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-6: 24px;
    --space-8: 32px;
    --space-12: 48px;

    --radius: 4px;
    --duration-fast: 120ms;
    --duration-base: 200ms;
    --ease-standard: cubic-bezier(0.2, 0, 0, 1);
}




/* Base
############################################################## */

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

html {
    background: var(--canvas);
}

body {
    min-height: 100vh;
    padding: var(--space-6);
    background:
        linear-gradient(180deg, rgba(16, 35, 45, 0.88) 0%, rgba(5, 12, 15, 0) 240px),
        var(--canvas);
    color: var(--text);
    font-family: Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    font-weight: 300;
    line-height: 1.5;
}

button,
input,
select {
    font: inherit;
}

button {
    letter-spacing: 0;
}



/* Typography
############################################################## */

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--primary-50);
    font-family: Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-weight: 900;
    letter-spacing: 0;
}

h1 {
    margin-bottom: var(--space-6);
    font-size: 26px;
    line-height: 26px;
}

h2 {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    font-size: 24px;
    line-height: 24px;
}

p {
    color: var(--text-muted);
}

a {
    color: var(--primary-100);
    text-decoration: none;
    transition: color var(--duration-fast) var(--ease-standard);
}

a:hover {
    color: var(--primary-25);
}

strong {
    font-weight: 700;
}



/* Page layout
############################################################## */

.container {
    max-width: var(--content-max-width);
    margin: 0 auto;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--line);
}

.header > div {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    justify-content: flex-end;
}

.page-title,
.brand-link h1 {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: 0;
}

.brand-link {
    color: var(--text);
}

.brand-link:hover {
    color: var(--text);
}

.icon {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

h1 .icon,
.page-title .icon {
    width: 26px;
    height: 26px;
    color: var(--primary-300);
}

h2 .icon {
    color: var(--primary-200);
}



/* Panels
############################################################## */

.card,
.stats {
    margin-bottom: var(--space-6);
    padding: var(--space-6);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(26, 30, 35, 0.94);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
}

.card p + p {
    margin-top: var(--space-2);
}

.box {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.9fr);
    gap: var(--space-6);
    align-items: stretch;
}

.fieldset {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
}

.stat-card {
    min-height: 118px;
    padding: var(--space-4);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
    text-align: left;
}

.stat-value {
    color: var(--primary-100);
    font-size: 40px;
    font-weight: 900;
    line-height: 1;
}

.stat-label {
    margin-top: var(--space-2);
    color: var(--text-subtle);
    font-size: 14px;
    font-weight: 300;
    line-height: 14px;
}



/* Forms
############################################################## */

.form-group {
    margin-bottom: var(--space-4);
}

label {
    display: block;
    margin-bottom: var(--space-2);
    color: var(--primary-50);
    font-size: 14px;
    font-weight: 700;
    line-height: 14px;
}

.field-hint {
    margin-left: var(--space-2);
    font-weight: 700;
}

.field-hint-error {
    color: var(--failure-200);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
select {
    width: 100%;
    min-height: 44px;
    padding: 10px var(--space-3);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--primary-950);
    color: var(--text);
    transition: border-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard), background-color var(--duration-fast) var(--ease-standard);
}

input::placeholder {
    color: var(--text-subtle);
}

input:hover,
select:hover {
    border-color: rgba(164, 203, 223, 0.44);
}

input:disabled,
select:disabled {
    background: var(--surface-raised) !important;
    color: var(--text-subtle);
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
    outline: none;
    border-color: var(--primary-300);
    box-shadow: 0 0 0 3px rgba(100, 166, 201, 0.32);
}



/* Buttons
############################################################## */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 44px;
    padding: 10px var(--space-4);
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 700;
    line-height: 14px;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard), opacity var(--duration-fast) var(--ease-standard);
}

.btn-primary {
	background: var(--primary-800);
	color: var(--primary-300);
}

.btn-primary:hover, .btn-primary:active {
	background: var(--primary-700);
	color: var(--primary-300);
}

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

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

.btn-secondary:hover,
.btn-secondary:active {
    background: var(--grey-700);
    color: var(--text);
}

.btn-danger {
    background: rgba(248, 99, 119, 0.08);
    border-color: rgba(248, 99, 119, 0.36);
    color: var(--failure-25);
}

.btn-danger:hover,
.btn-danger:active {
    background: rgba(248, 99, 119, 0.18);
    color: var(--failure-25);
}

.btn-sm {
    min-height: 32px;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius);
    font-size: 14px;
}

.btn-icon {
    width: 32px;
    min-width: 32px;
    height: 32px;
    min-height: 32px;
    padding: 0;
}

.copy-btn,
.preview-btn,
.log-btn,
.modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-raised);
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard);
}

.copy-btn:hover,
.preview-btn:hover,
.log-btn:hover,
.modal-close:hover {
    border-color: rgba(164, 203, 223, 0.44);
    background: var(--grey-700);
    color: var(--primary-50);
}

.copy-btn.copied {
    color: var(--success-25);
    border-color: rgba(14, 203, 129, 0.45);
    background: rgba(14, 203, 129, 0.16);
}



/* Feedback
############################################################## */

.floating-alerts {
    position: fixed;
    top: var(--space-6);
    right: max(var(--space-4), calc((100vw - var(--content-max-width)) / 2));
    z-index: 1000;
    width: min(420px, calc(100vw - 32px));
    transform: translateY(0);
    transition: opacity 300ms var(--ease-standard), visibility 300ms var(--ease-standard), transform 300ms var(--ease-standard);
}

.floating-alerts.is-hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-12px);
}

.floating-alerts[hidden] {
    display: none;
}

.floating-alerts .alert:last-child {
    margin-bottom: 0;
}

.alert {
    margin-bottom: var(--space-4);
    padding: var(--space-4);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    font-weight: 700;
}

.alert-success {
    color: var(--success-25);
    border-color: rgba(14, 203, 129, 0.38);
    background: rgba(14, 203, 129, 0.12);
}

.alert-error {
    color: var(--failure-25);
    border-color: rgba(248, 99, 119, 0.38);
    background: rgba(248, 99, 119, 0.12);
}



/* QR code table
############################################################## */

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

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

th {
    background: rgba(43, 49, 57, 0.52);
    color: var(--text-subtle);
    font-size: 14px;
    font-weight: 700;
    line-height: 14px;
}

td {
    color: var(--text);
}

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

tr:hover {
    background: rgba(48, 105, 136, 0.14);
}

.qr-url-cell {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.qr-url {
    max-width: 260px;
    padding: 5px var(--space-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--primary-950);
    color: var(--text-muted);
    font-family: "Roboto Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.target-url {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.last-changed {
    display: flex;
    flex-direction: row;
    align-items: center;
}

.log-btn {
    margin-left: var(--space-2);
}

.actions {
    white-space: nowrap;
}

.actions a,
.actions button {
    margin-right: 0;
}



/* Status badges
############################################################## */

.status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 86px;
    min-height: 24px;
    padding: 4px var(--space-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-raised);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 700;
    line-height: 14px;
}

.status-active,
.status-ok {
    color: var(--success-25);
    border-color: rgba(14, 203, 129, 0.34);
    background: rgba(14, 203, 129, 0.12);
}

.status-inactive {
    color: var(--text-subtle);
}

.status-error {
    color: var(--failure-25);
    border-color: rgba(248, 99, 119, 0.34);
    background: rgba(248, 99, 119, 0.12);
}



/* Login
############################################################## */

.login-container {
    max-width: 420px;
    margin: 80px auto;
}

.login-container h1 {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.login-note {
    margin-bottom: var(--space-6);
    text-align: left;
}



/* Modals
############################################################## */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    inset: 0;
    padding: var(--space-6);
    background-color: rgba(5, 12, 15, 0.82);
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    width: min(800px, 100%);
    max-height: 90vh;
    overflow: auto;
    padding: var(--space-6);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background-color: var(--surface);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.modal-header h2 {
    margin: 0;
}

.modal-close {
    font-size: 0;
}

.modal-wide {
    max-width: 920px;
}

.modal-qr-preview {
    max-width: 420px;
}

.qr-preview {
    display: grid;
    justify-items: center;
    gap: var(--space-4);
}

.qr-preview img {
    width: min(100%, 320px);
    height: auto;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
}

.qr-preview-url {
    max-width: 100%;
    padding: var(--space-2) 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--primary-950);
    color: var(--text-muted);
    font-family: "Roboto Mono", "SFMono-Regular", Consolas, monospace;
    overflow-wrap: anywhere;
    text-align: center;
}

.log-content {
    max-height: 500px;
    overflow-y: auto;
}



/* Utilities
############################################################## */

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

.full-width {
    width: 100%;
}

.empty-state,
.loading-state {
    padding: var(--space-6) 0;
}

.loading-state {
    text-align: center;
}

.mt-xs {
    margin-top: var(--space-1);
}

.nowrap {
    white-space: nowrap;
}

.small-text {
    font-size: 14px;
}

.inline-actions {
    display: flex;
    gap: var(--space-2);
    justify-content: flex-end;
}



/* Responsive
############################################################## */

@media (max-width: 960px) {
    .box {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    body {
        padding: var(--space-4);
    }

    .header {
        align-items: flex-start;
        flex-direction: column;
    }

    .header > div {
        justify-content: flex-start;
        width: 100%;
    }

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

    .card,
    .stats,
    .modal-content {
        padding: var(--space-4);
    }

    .fieldset {
        grid-template-columns: 1fr;
    }

    .modal {
        padding: var(--space-4);
    }

    table {
        min-width: 860px;
    }
}
