/* Modern, Secure, No-JS WebUI Styles */
:root {
    /* Color Palette */
    --bg-body: #050608;
    --bg-panel: #0f1115;
    --bg-input: #090a0d;
    
    --border-light: #1f2329;
    --border-focus: #3b82f6;
    
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --text-accent: #38bdf8;
    
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-text: #ffffff;
    
    --danger: #ef4444;
    --success: #10b981;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
}

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

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* Layout */
.page-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

main.container {
    flex: 1;
    padding-top: 2rem;
    padding-bottom: 4rem;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-main);
    font-weight: 700;
    line-height: 1.2;
}

h1 { font-size: 1.875rem; margin-bottom: 0.5rem; }
h2 { font-size: 1.25rem; margin-bottom: 0.5rem; }

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

a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.muted { color: var(--text-muted); }
.small { font-size: 0.875rem; }
.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

/* Navigation */
.topbar {
    background-color: rgba(15, 17, 21, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 0.75rem 0;
}

.bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.brand {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.025em;
    display: flex;
    align-items: center;
}

.brand-logo {
    height: 36px;
    width: auto;
    display: block;
}

.nav-links {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.nav-links a {
    color: var(--text-muted);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.05);
}

.logout {
    margin-left: auto;
}

.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-light);
    line-height: 1;
}

.nav-badge.dot {
    padding: 0 0.35rem;
}

.nav-badge.money {
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.5);
    background: rgba(16, 185, 129, 0.08);
}

.nav-badge.muted {
    color: var(--text-muted);
}

/* Cards & Containers */
.card {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.grid {
    display: grid;
    gap: 1.5rem;
}

.grid.products {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* Product Card */
.product {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.product-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.product-head.minimalist h2 {
    font-size: 1.05rem;
    margin-bottom: 0.25rem;
}

.price {
    font-weight: 700;
    color: var(--success);
    font-size: 1.125rem;
    white-space: nowrap;
}

/* Forms & Inputs */
label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.375rem;
}

.input, input[type="text"], input[type="password"], input[type="number"], input[type="email"] {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 0.625rem 0.875rem;
    color: var(--text-main);
    font-size: 0.9375rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input:focus, input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.qty {
    width: 5rem !important;
    text-align: center;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.9375rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    text-decoration: none;
    line-height: 1.25;
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

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

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

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

.btn.ghost:hover {
    color: var(--text-main);
    border-color: var(--text-muted);
    background-color: rgba(255, 255, 255, 0.03);
}

.btn.full {
    width: 100%;
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    background-color: var(--bg-panel);
}

.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.table th, .table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

.table th {
    background-color: rgba(255, 255, 255, 0.02);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

.table td:last-child, .table th:last-child {
    text-align: right;
}

/* Flash Messages */
.flash {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.flash-item {
    padding: 1rem;
    border-radius: var(--radius-md);
    background-color: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    color: var(--text-accent);
    font-weight: 500;
}

/* Auth Page */
.auth {
    max-width: 400px;
    margin: 4rem auto;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 1rem;
}

.summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
    margin-top: 1rem;
    font-weight: 700;
    font-size: 1.125rem;
}

.order-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.order-footer-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

.order-footer-actions .btn {
    min-width: 170px;
}

.order-footer-right {
    display: flex;
    gap: 1rem;
    margin-left: auto;
}

@media (max-width: 640px) {
    .order-footer-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .order-footer-right {
        margin-left: 0;
        width: 100%;
        flex-direction: column;
    }
}

/* Utilities */
.actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cta-row {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.cta-center {
    justify-content: center;
    flex-wrap: wrap;
}

.table-only { display: block; }
.mobile-only { display: none !important; }

.card-list {
    display: grid;
    gap: 1rem;
}

.card-list:not(.mobile-only) {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.card-row {
    padding: 1rem;
}

.row-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}

.row-title {
    font-weight: 700;
}

.row-meta {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.row-kv {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.35rem 0;
    border-top: 1px dashed var(--border-light);
}

.section-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.5rem 0 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.75rem;
    font-weight: 600;
}

.section-divider::before,
.section-divider::after {
    content: "";
    height: 1px;
    background: var(--border-light);
    flex: 1;
}

.section-divider span {
    white-space: nowrap;
}

.info-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-left: 0;
    color: var(--text-muted);
}

.info-list li {
    padding-left: 1.25rem;
    position: relative;
}

.info-list li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--text-accent);
}


@media (max-width: 640px) {
    .bar {
        flex-direction: column;
        align-items: stretch;
    }

    .brand {
        width: 100%;
        justify-content: center;
    }
    
    .nav-links {
        justify-content: center;
        width: 100%;
    }
    
    .nav-links a {
        flex: 1;
        text-align: center;
    }
    
    .logout {
        margin-left: 0;
        width: 100%;
    }
    
    .logout .btn {
        width: 100%;
    }
    
    .section-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .cta-row {
        flex-direction: column;
    }

    .table-only { display: none !important; }
    .mobile-only { display: grid !important; }

    .table {
        min-width: 0;
        font-size: 0.9rem;
    }

    .table th, .table td {
        padding: 0.75rem;
    }
}

/* Flash Messages - Categories */
.flash-item.error {
    background-color: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.flash-item.success {
    background-color: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.flash-item.info {
    background-color: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.2);
    color: var(--text-accent);
}

/* Icons */
.nav-links a svg, .btn svg {
    width: 18px;
    height: 18px;
    vertical-align: text-bottom;
    margin-right: 6px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
}

.page-info {
    color: var(--text-muted);
    font-size: 0.9375rem;
}

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

/* Badges & balances */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    background: rgba(255,255,255,0.04);
    color: var(--text-main);
    font-weight: 600;
}
.badge.success {
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.35);
    background: rgba(16, 185, 129, 0.08);
}
.badge.info {
    color: var(--text-accent);
    border-color: rgba(59, 130, 246, 0.35);
    background: rgba(59, 130, 246, 0.08);
}
.badge.error {
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.08);
}
.badge.amount {
    background: linear-gradient(135deg, #0f172a, #0b1323);
    border-color: #1f2937;
    box-shadow: var(--shadow-md);
}
.badge.status.pending { color: var(--text-accent); }
.badge.status.completed { color: var(--success); }
.badge.status.resolved { color: var(--success); }
.badge.status.error, .badge.status.rejected { color: var(--danger); }

.balance-display {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.balance-display .label { color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.8rem; }
.balance-display .value { font-size: 2rem; font-weight: 800; color: var(--text-main); }
.balance-display .unit { font-size: 1rem; color: var(--text-muted); margin-left: 6px; }

.secret {
    width: 100%;
    min-height: 200px;
    background: var(--bg-input);
    border: 1px dashed var(--border-light);
    color: var(--text-main);
    padding: 1rem;
    border-radius: var(--radius-md);
    font-family: "SFMono-Regular", Menlo, Consolas, monospace;
}

.qty-quick {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}


.message-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.chat-thread {
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 0.85rem;
    max-height: 420px;
    overflow-y: auto;
}

.message-card {
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 0.35rem 0.7rem;
    max-width: 72%;
}

.message-card.user {
    border-color: rgba(59, 130, 246, 0.25);
    background: rgba(59, 130, 246, 0.08);
    align-self: flex-end;
    text-align: right;
}

.message-card.staff {
    border-color: rgba(16, 185, 129, 0.25);
    background: rgba(16, 185, 129, 0.08);
    align-self: flex-start;
    text-align: left;
}

.message-meta {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.2rem;
}

.message-meta .sender {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.message-meta .time {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.1;
}

.message-meta .meta-sep {
    color: var(--text-muted);
}

.message-date-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.4rem 0 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.75rem;
    font-weight: 700;
}

.message-date-divider::before,
.message-date-divider::after {
    content: "";
    height: 1px;
    background: var(--border-light);
    flex: 1;
}

.dt-date {
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.02em;
}

.dt-time {
    color: var(--text-main);
    font-weight: 700;
    margin-left: 0;
}

.dt-stack {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.1;
    gap: 0.2rem;
}

.message-body {
    white-space: pre-wrap;
    font-size: 0.95rem;
    line-height: 1.35;
}

.chat-composer {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
    margin-top: 0;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
}

.chat-composer .chat-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.65rem;
}

.chat-composer textarea.input {
    min-height: 56px;
    resize: vertical;
    border: none;
    background: transparent;
    padding: 0;
}

.chat-composer .btn {
    align-self: center;
    height: 42px;
    padding: 0 1.25rem;
}

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

.qty-row .input.qty {
    width: 6rem !important;
}

@media (max-width: 640px) {
    .table-only { display: none !important; }
    .mobile-only { display: grid !important; }
}
