﻿:root {
    --surface: #ffffff;
    --surface-muted: #f8f9fa;
    --surface-strong: #e9ecef;
    --primary: #0b7285;
    --primary-dark: #075063;
    --danger: #e03131;
    --danger-dark: #c92a2a;
    --text: #1f2933;
    --text-muted: #495057;
    --text-light: #868e96;
    --shadow: 0 20px 40px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(160deg, #e8f6ff 0%, #f4f6f8 35%, #fdfdfd 100%);
    margin: 0;
    padding: 32px 16px;
    color: var(--text);
}

/* Autosuggest loading state */
#process_suggestions.loading::before {
    content: attr(data-loading-text);
    display: block;
    padding: 4px 8px;
    font-size: 0.75rem;
    color: var(--text-light);
    font-style: italic;
}

.container {
    width: min(960px, 100%);
    margin: 0 auto;
    background: var(--surface);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 28px 24px 40px;
    display: grid;
    gap: 24px;
}

/* Top navigation bar */
.top-nav {
    background: linear-gradient(90deg, rgba(11,114,133,0.05), rgba(11,114,133,0.03));
    border-bottom: 1px solid rgba(0,0,0,0.04);
    padding: 10px 0;
}
.top-nav .nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.nav-tools {
    display: flex;
    align-items: center;
    gap: 12px;
}
.token-badge {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,0.85);
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(0,0,0,0.04);
    box-shadow: 0 4px 10px rgba(15,23,42,0.04);
    font-size: 0.85rem;
}
.token-badge .token-label {
    color: var(--text-light);
    font-weight: 600;
}
.token-badge .token-value {
    font-weight: 700;
    color: var(--primary-dark);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.token-badge .token-actions { display: inline-flex; gap: 6px; }
.token-badge button { padding: 6px 8px; font-size: 0.8rem; }
.nav-brand {
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    font-size: 1.05rem;
    margin-right: 12px;
}
/* Company logo in header */
.nav-logo {
    display: inline-block;
    height: auto;
    max-height: 40px; /* cap height on desktop */
    width: auto;
    vertical-align: middle;
    margin-right: 10px;
}

/* Slightly smaller logo on mobile */
@media (max-width: 640px) {
    .nav-logo { max-height: 32px; margin-right: 8px; }
}

/* When viewing admin pages, use a smaller logo to avoid visual imbalance */
.admin-page .nav-logo {
    max-height: 28px;
}
.nav-links {
    display: flex;
    align-items: center;
    gap: 12px;
}
.nav-links a {
    margin-left: 0;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
}

/* Admin-only nav links are hidden by default and revealed when an admin token
   exists; the JS bootstrap toggles .show-admin on .nav-links when admin token
   is detected. This prevents non-admin users from seeing admin controls. */
.top-nav .nav-links .admin-link { display: none; }
.top-nav .nav-links.show-admin .admin-link { display: inline-block; }
.nav-links a:hover {
    color: var(--primary);
}

/* hide mobile nav toggle by default; shown only on small screens */
.nav-toggle {
    display: none;
}

.nav-item.has-submenu > a::after {
    content: '\25BE'; /* small down-pointing triangle */
    display: inline-block;
    margin-left: 6px;
    font-size: 0.7em;
    vertical-align: middle;
    color: var(--text-light);
}
.nav-item.has-submenu > a:focus,
.nav-item.has-submenu > a:hover {
    color: var(--primary);
}

/* Dropdown submenu for company links under Home */
.nav-item {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.nav-item .submenu {
    position: absolute;
    left: 0;
    /* overlap slightly with the link to avoid a pointer gap when moving from link -> submenu */
    top: calc(100% - 2px);
    min-width: 160px;
    background: var(--surface);
    border: 1px solid var(--surface-strong);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    padding: 8px 6px;
    display: none;
    z-index: 40;
}
.nav-item .submenu a {
    display: block;
    padding: 8px 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    border-radius: 6px;
}
.nav-item .submenu a:hover {
    background: rgba(11,114,133,0.06);
    color: var(--primary);
}
.nav-item.has-submenu:hover .submenu,
.nav-item.has-submenu:focus-within .submenu,
.nav-item.has-submenu.open .submenu {
    display: block;
}

@media (max-width: 640px) {
    /* On small screens make submenu inline and full-width */
    .nav-item .submenu {
        position: static;
        top: auto;
        left: auto;
        box-shadow: none;
        border: none;
        padding: 6px 0;
        display: block;
    }
    .nav-item .submenu a {
        padding: 8px 0;
        margin-left: 0;
    }
}

/* Active nav link */
.nav-links a.active {
    color: var(--primary);
    background: rgba(11,114,133,0.08);
    padding: 6px 10px;
    border-radius: 8px;
}

/* Make the top-nav more compact and visually separated */
.top-nav {
    padding: 12px 0;
}
.top-nav .nav-inner {
    width: min(1100px, 100%);
    margin: 0 auto;
    padding: 0 12px;
}

@media (max-width: 640px) {
    /* Keep brand, toggle and token on a single row for compact mobile header */
    .top-nav .nav-inner {
        flex-direction: row;
        gap: 12px;
        align-items: center;
        justify-content: space-between;
    }
    .nav-links a { margin-left: 0; }
    .nav-tools { display: flex; align-items: center; gap: 8px; }
    .token-badge { width: auto; justify-content: center; }

    /* Mobile nav: hide links behind toggle */
    .nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 8px 10px;
        font-size: 1rem;
        border-radius: 8px;
        border: none;
        background: var(--surface);
        cursor: pointer;
    }

    .nav-links {
        display: none; /* hidden until nav-open */
        width: 100%;
        flex-direction: column;
        gap: 8px;
    }

    .nav-inner.nav-open .nav-links {
        display: flex;
    }

    /* Mobile submenu become collapsible blocks */
    .nav-item .submenu {
        display: none !important;
        position: static;
        padding-left: 12px;
    }
    .nav-item.open .submenu {
        display: block !important;
    }
}

/* Mobile nav flow fixes: ensure menu is not clipped and flows under header */
@media (max-width: 640px) {
    .top-nav { position: relative; z-index: 60; }
    .top-nav .nav-inner { width: 100%; box-sizing: border-box; flex-wrap: wrap; }
    .top-nav .nav-inner.nav-open { align-items: flex-start; }

    /* When opened, present nav-links as a full-width stacked block below the header */
    .nav-links {
        background: linear-gradient(90deg, rgba(11,114,133,0.03), rgba(11,114,133,0.01));
        padding: 10px 12px;
        border-radius: 12px;
        box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    }

    .nav-tools { flex-shrink: 0; }
    .nav-brand { flex-shrink: 1; }
}

/* Additional targeted mobile improvements */
@media (max-width: 640px) {
    /* Ensure brand, toggle, and token align horizontally and have predictable sizing */
    .nav-brand { order: 1; }
    .nav-toggle { order: 2; }
    .nav-tools { order: 3; }
    .nav-links { order: 4; }

    .nav-brand a { display: inline-flex; align-items: center; gap: 8px; padding: 6px 8px; }

    /* Make token badge compact and friendly for touch */
    .token-badge { padding: 8px 10px; font-size: 0.85rem; border-radius: 12px; }
    .token-badge .token-actions button { padding: 8px 10px; font-size: 0.9rem; }

    /* Increase tappable area for nav links shown in mobile menu */
    .nav-links a { padding: 12px 10px; font-size: 1rem; display: block; width: 100%; }
    .nav-item .submenu a { padding: 12px 12px; }

    /* Stack form fields and make inputs bigger for touch */
    .form-grid { grid-template-columns: 1fr !important; }
    input, select, textarea { padding: 14px 16px; font-size: 1.05rem; }

    /* Make primary actions full-width and prominent */
    .primary-button, .secondary-button, .danger-button { width: 100%; padding: 14px 18px; font-size: 1.02rem; border-radius: 12px; }

    /* Table cards: reduce inner padding slightly to fit screens but keep readability */
    .table-wrapper tr { padding: 12px; }

    /* Ensure local-only badge sits under the field on mobile */
    .local-only-badge { display: inline-block; margin-top: 8px; }

    /* Make small control buttons (copy/clear) larger on mobile for easier tapping */
    .token-badge .token-actions button, .table-actions button { padding: 10px 12px; }
}

.page-header {
    display: grid;
    gap: 8px;
    text-align: center;
}

.page-header h1 {
    margin: 0;
    font-size: clamp(1.75rem, 1.2rem + 1.5vw, 2.25rem);
    color: var(--primary);
}

.page-description {
    margin: 0;
    color: var(--text-light);
    font-size: 0.95rem;
}

.entry-form {
    display: grid;
    gap: 20px;
    background: var(--surface-muted);
    border-radius: 16px;
    padding: 20px;
}

.form-grid {
    display: grid;
    gap: 16px;
}

/* Two-column form used by cluster productivity page: left (company/line), right (cluster/productivity) */
.form-grid.two-column {
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    align-items: start;
}
.form-grid.two-column .column {
    display: grid;
    gap: 12px;
}

/* Multi-cluster 2x2 grid for C1..C4 inputs */
.multi-cluster-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}
.cluster-cell { display:flex; flex-direction:column; }
.cluster-cell label { font-weight:600; margin-bottom:4px; }

/* Make cluster entries table visually consistent with other tables */
.cluster-entries {
    margin-top: 18px;
}
.cluster-entries .entries-table {
    width: 100%;
    border-collapse: collapse;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--surface-strong);
    background: var(--surface);
}
.cluster-entries .entries-table th,
.cluster-entries .entries-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--surface-strong);
}
.cluster-entries .entries-table thead { background: #f1fbff; }

@media (max-width: 640px) {
    /* stack the two columns into a single column on small screens */
    .form-grid.two-column {
        grid-template-columns: 1fr !important;
    }
    .form-grid.two-column .column { gap: 10px; }
    .cluster-entries .entries-table thead { display: none; }
    .cluster-entries .entries-table, .cluster-entries .entries-table tbody, .cluster-entries .entries-table tr {
        display: block;
        width: 100%;
    }
    .cluster-entries .entries-table tr { margin-bottom: 12px; border-radius: 12px; border: 1px solid var(--surface-strong); padding: 12px; background: var(--surface); }
    .cluster-entries .entries-table td { display: block; border: none; padding: 8px 0; }
    .cluster-entries .entries-table td::before { content: attr(data-label); display: block; font-size: 0.75rem; color: var(--text-light); margin-bottom: 4px; text-transform: uppercase; }
}

/* Force a single-column layout for compact admin forms (product info) */
.single-column .form-grid {
    grid-template-columns: 1fr;
}

.field {
    display: grid;
    gap: 8px;
}

label {
    font-weight: 600;
    color: var(--text-muted);
}

input,
select {
    padding: 12px 14px;
    font-size: 1rem;
    border-radius: 10px;
    border: 1px solid var(--surface-strong);
    transition: border 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
    background: #fff;
    color: var(--text);
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(11, 114, 133, 0.2);
}

/* Product suggestions dropdown (custom, complements datalist) */
.product-suggest { position: relative; }
.process-suggest { position: relative; }
.product-suggest .suggestions,
.process-suggest .suggestions {
    position: absolute;
    z-index: 80;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid rgba(0,0,0,0.06);
    box-shadow: 0 12px 30px rgba(15,23,42,0.12);
    border-radius: 8px;
    max-height: 220px;
    overflow: auto;
    margin-top: 8px;
}
.suggestion-row {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    cursor: pointer;
    color: var(--text);
    background: transparent;
}
.suggestion-row:hover, .suggestion-row.active {
    background: rgba(11,114,133,0.06);
}
.suggestion-code { font-weight: 700; color: var(--primary-dark); }
.suggestion-name { display: none; }
/* Show process name text in process autosuggest */
.process-suggest .suggestion-name { display: block; color: var(--text-muted); font-size: 0.95rem; }


.primary-button,
.danger-button {
    padding: 12px 24px;
    font-size: 0.98rem;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.primary-button {
    background-color: var(--primary);
    color: #fff;
    box-shadow: 0 10px 20px rgba(11, 114, 133, 0.25);
}

/* Admin products table: show code and name stacked in first column */
/* .table-wrapper table td, .table-wrapper table th { padding: 14px 18px; } */
.product-code-wrap { display: flex; flex-direction: column; gap: 6px; }
.product-code { font-weight: 700; color: var(--primary-dark); font-size: 0.98rem; }
.product-name { color: var(--text-muted); font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Make table responsive: allow columns to shrink and keep first column wide enough */
.table-wrapper table { width: 100%; border-collapse: collapse; }
.table-wrapper table th, .table-wrapper table td { text-align: left; vertical-align: middle; }

@media (max-width: 900px) {
    .table-wrapper table th:first-child, .table-wrapper table td:first-child { width: 50%; }
}

@media (max-width: 640px) {
    .table-wrapper table { font-size: 0.95rem; }
    .product-name { white-space: normal; }
}

.primary-button:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
}

.primary-button:active {
    transform: translateY(0);
    box-shadow: 0 6px 16px rgba(11, 114, 133, 0.25);
}

.primary-button.ghost {
    background: rgba(11, 114, 133, 0.08);
    color: var(--primary);
    border: 1px solid rgba(11, 114, 133, 0.2);
    box-shadow: none;
}

.primary-button.ghost:hover {
    background: rgba(11, 114, 133, 0.16);
}

.danger-button {
    background: var(--danger);
    color: #fff;
    box-shadow: 0 10px 20px rgba(224, 49, 49, 0.2);
}

.danger-button:hover {
    background: var(--danger-dark);
    transform: translateY(-1px);
}

.alert {
    padding: 14px 16px;
    border-radius: 14px;
    margin: 0;
    font-size: 0.95rem;
    border: 1px solid transparent;
}

.alert.success {
    background-color: #e6fcf5;
    color: #066649;
    border-color: #63e6be;
}

.alert.error {
    background-color: #fff5f5;
    color: #b21f1f;
    border-color: #ffa8a8;
}

.entries-section {
    display: grid;
    gap: 16px;
}

.section-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.section-header h2 {
    margin: 0;
    font-size: 1.35rem;
    color: var(--text);
}

.section-header p {
    margin: 0;
    color: var(--text-light);
    font-size: 0.9rem;
}

.table-wrapper {
    border-radius: 18px;
    border: 1px solid var(--surface-strong);
    overflow: hidden;
    background: #ffffff;
}

.table-wrapper table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

table thead {
    background-color: #ecf9ff;
}

table th,
table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--surface-strong);
    color: var(--text);
    vertical-align: middle;
}

table th {
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-light);
}

table tbody tr:last-child td {
    border-bottom: none;
}

table tbody tr:hover {
    background-color: rgba(11, 114, 133, 0.08);
}

.empty-state {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-light);
    border: 2px dashed var(--surface-strong);
    border-radius: 18px;
    background: var(--surface-muted);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(11, 114, 133, 0.1);
    color: var(--primary);
}

.status-pill.pending {
    background: rgba(250, 176, 5, 0.12);
    color: #b07609;
}

.status-pill.approved {
    background: rgba(12, 166, 120, 0.12);
    color: #0b8a5c;
}

/* Keep status cell content centered on desktop too */
.status-cell { align-items: center; gap: 8px; }

.actions-cell {
    column-count: 1;
    column-gap: 8px;
}

.actions-cell > * {
    break-inside: avoid;
    margin-bottom: 8px;
}

/* Subtle info row under a record when supervisor modified quantity */
.modified-note {
    font-size: 0.9rem;
    color: var(--text-light);
    background: rgba(11,114,133,0.04);
    padding: 8px 12px;
}

/* Subtle ghost danger button for row actions */
.ghost-danger {
    background: transparent;
    border: 1px solid rgba(224, 49, 49, 0.25);
    color: var(--danger);
    padding: 8px 12px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.ghost-danger:hover {
    background: rgba(224, 49, 49, 0.06);
}
.ghost-danger svg { display: inline-block; }

.xacnhansanluong.container {
    width: min(1120px, 100%);
    gap: 28px;
    padding: 32px 28px 44px;
}

.xacnhansanluong .filter-section {
    background: var(--surface-muted);
    border-radius: 18px;
    padding: 24px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.xacnhansanluong .filter-form {
    display: grid;
    gap: 20px;
}

.xacnhansanluong .filter-form .form-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.xacnhansanluong .filter-actions {
    display: flex;
    justify-content: flex-end;
}

.xacnhansanluong .table-wrapper table {
    min-width: 860px;
}

@media (min-width: 640px) {
    body {
        padding: 48px 24px;
    }

    .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .field-span {
        grid-column: 1 / -1;
    }

    .section-header {
        align-items: center;
        justify-content: space-between;
        flex-direction: row;
    }
}

@media (max-width: 768px) {
    .xacnhansanluong.container {
        padding: 24px 18px 32px;
    }

    .xacnhansanluong .filter-section {
        padding: 18px;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 24px 16px 32px;
        border-radius: 16px;
    }

    .entry-form {
        padding: 16px;
    }

    .primary-button,
    .danger-button {
        width: 100%;
        justify-content: center;
    }

    .table-wrapper {
        border: none;
        background: transparent;
        overflow: visible;
    }

    .table-wrapper table {
        min-width: 100%;
        background: transparent;
    }

    .table-wrapper thead {
        display: none;
    }

    .table-wrapper tbody {
        display: grid;
        gap: 12px;
    }

    .table-wrapper tr {
        display: grid;
        gap: 12px;
        padding: 16px;
        border-radius: 16px;
        border: 1px solid var(--surface-strong);
        background: var(--surface);
        box-shadow: 0 12px 24px rgba(15, 23, 42, 0.06);
    }

    .table-wrapper td {
        border: none;
        padding: 0;
    }

    .table-wrapper td::before {
        content: attr(data-label);
        display: block;
        font-size: 0.75rem;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: var(--text-light);
        margin-bottom: 4px;
    }

    /* Compact two-column layout for cardified rows to reduce vertical length */
    .table-wrapper tr {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start;
    }

    /* Make only the actions cell span full width beneath the two columns; keep status next to submitted time */
    .table-wrapper tr td:nth-child(9) {
        grid-column: 1 / -1;
    }

    /* Align status pill nicely when it's placed in the second column */
    .table-wrapper tr td:nth-child(8) { align-items: center; }
    .table-wrapper tr td:nth-child(8) .status-pill { margin: 0; }

    /* Reduce spacing for label prefix so label sits closer to value */
    .table-wrapper td::before { margin-bottom: 2px; font-size: 0.72rem; }

    /* Slightly smaller value font to keep cards compact */
    .table-wrapper td { font-size: 0.98rem; }

    .actions-cell {
        flex-direction: column;
    }
}

/* Fix for confirmation page where a more specific selector set a large min-width
   (e.g. .xacnhansanluong .table-wrapper table { min-width: 860px }) — override it
   on small screens so the cardified rows fit the viewport and avoid horizontal scroll. */
@media (max-width: 640px) {
    .xacnhansanluong .table-wrapper {
        overflow: visible;
        padding: 0;
        border: none;
        background: transparent;
    }
    .xacnhansanluong .table-wrapper table {
        min-width: 100% !important;
        background: transparent;
    }
    /* ensure table cards don't get extra internal horizontal padding */
    .xacnhansanluong .table-wrapper tr {
        padding-left: 12px;
        padding-right: 12px;
    }
}

/* Make the first column (Chuyền) in the confirmation table narrower and centered
   so it visually aligns with other columns. Scoped to the confirmation page only. */
.xacnhansanluong .table-wrapper table th:first-child,
.xacnhansanluong .table-wrapper table td:first-child {
    width: 90px; /* fixed small width for short values like '12', '12A' */
    max-width: 90px;
    text-align: center;
    white-space: nowrap;
}

/* For very small screens, let the column shrink but keep label clarity */
@media (max-width: 640px) {
    .xacnhansanluong .table-wrapper tr {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .xacnhansanluong .table-wrapper table th:first-child,
    .xacnhansanluong .table-wrapper table td:first-child {
        width: auto;
        max-width: none;
        text-align: left;
    }
}

/* Also apply a balanced width for 'Chuyền' column in entry list tables to avoid
   a single oversized first column across the entries page. This keeps table
   columns visually even. */
.entries-section .table-wrapper table th:first-child,
.entries-section .table-wrapper table td:first-child {
    width: 100px;
}

@media (max-width: 900px) {
    .entries-section .table-wrapper table th:first-child,
    .entries-section .table-wrapper table td:first-child {
        width: max-content;
    }
}


.status-pill .status-detail {
    font-weight: 500;
    font-size: 0.8rem;
    color: var(--text-light);
}

/* Badge for entries that exist only on this device */
.local-only-badge {
    display: inline-block;
    background: rgba(107, 114, 255, 0.08);
    color: #4f46e5;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-left: 8px;
}

@media (max-width: 640px) {
    .local-only-badge {
        margin-left: 0;
        margin-top: 8px;
        display: inline-block;
    }
}


.status-pill .status-label {
    font-weight: 600;
}


.actions-info {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-light);
}


.static-field {
    display: grid;
    gap: 6px;
}

.static-value {
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--surface-muted);
    border: 1px solid var(--surface-strong);
    font-weight: 600;
    color: var(--text);
}

textarea {
    padding: 12px 14px;
    font-size: 1rem;
    border-radius: 10px;
    border: 1px solid var(--surface-strong);
    transition: border 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
    resize: vertical;
    min-height: 120px;
    background: #fff;
    color: var(--text);
}

textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(11, 114, 133, 0.2);
}

.secondary-button {
    padding: 10px 22px;
    font-size: 0.95rem;
    border-radius: 999px;
    border: 1px solid var(--surface-strong);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.secondary-button:hover {
    background: var(--surface-muted);
    transform: translateY(-1px);
}

.secondary-button:active {
    transform: translateY(0);
}

.admin-supervisors .admin-form-section {
    display: grid;
    gap: 16px;
}

.admin-supervisors .admin-form {
    display: grid;
    gap: 20px;
    background: var(--surface-muted);
    border-radius: 16px;
    padding: 20px;
}

.admin-supervisors .admin-form .form-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

/* Layout improvements for admin page: place form and table side-by-side on wide screens */
.admin-content {
    display: grid;
    gap: 24px;
}

@media (min-width: 980px) {
    .admin-content {
        grid-template-columns: 420px 1fr;
        align-items: start;
    }

    /* Make the admin form visually anchored and consistent width */
    .admin-supervisors .admin-form {
        padding: 20px;
        border-radius: 14px;
    }

    /* Table should not force horizontal scroll unnecessarily */
    .admin-supervisors .admin-table-section .table-wrapper table {
        min-width: 0;
        table-layout: auto;
    }

    .admin-supervisors .admin-table-section {
        display: block;
    }
}

/* Visual refinements for table and headings */
.admin-supervisors .section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.admin-supervisors .section-header h2 {
    margin: 0;
    font-size: 1.15rem;
    color: var(--text);
}

/* Reduce table header height and tighten cells */
.admin-supervisors .table-wrapper table thead th {
    padding: 10px 12px;
}
.admin-supervisors .table-wrapper table td {
    padding: 10px 12px;
}

/* Limit token column and prevent awkward wrapping */
.admin-supervisors .table-wrapper table td:first-child {
    max-width: 140px;
    min-width: 100px;
    overflow-wrap: anywhere;
    white-space: normal;
}

/* Make table header labels slightly smaller to fit */
.admin-supervisors .table-wrapper table th {
    font-size: 0.78rem;
}

/* Ensure the two column headings align visually with the panels */
.admin-supervisors .admin-form-section h2,
.admin-supervisors .admin-table-section .section-header h2 {
    line-height: 1.2;
}

/* Slightly smaller action buttons and consistent radius */
.admin-supervisors .table-actions button {
    padding: 6px 10px;
    font-size: 0.9rem;
    border-radius: 8px;
}

/* Improve spacing under the form (link area) */
.admin-supervisors .generated-link {
    background: transparent;
    padding: 8px 0 0 0;
}

/* Make the empty-state box align visually with table */
.admin-supervisors .empty-state {
    margin-top: 8px;
}

/* Small visual adjustments */
.admin-supervisors .form-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.admin-supervisors #created_link {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-supervisors .generated-value {
    display: flex;
    gap: 8px;
}

.admin-supervisors input[readonly]#created_link_input {
    flex: 1 1 auto;
}

/* Tighten table cell spacing for readability */
.admin-supervisors .table-wrapper table th,
.admin-supervisors .table-wrapper table td {
    padding: 12px 14px;
}

/* Ensure action buttons are consistent size */
.admin-supervisors .table-actions button {
    padding: 8px 12px;
    font-size: 0.92rem;
}

.admin-supervisors .field-full {
    grid-column: 1 / -1;
}

.admin-supervisors .field-help {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-light);
}

.table-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Ensure action column has enough room and buttons align to the right without overlapping */
.admin-supervisors .table-wrapper table th:last-child,
.admin-supervisors .table-wrapper table td:last-child {
    width: 180px; /* reserve space for action buttons */
    white-space: nowrap;
}

.admin-supervisors .table-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: nowrap; /* prefer single-line buttons; they will shrink if necessary */
}

.admin-supervisors .table-actions button {
    white-space: nowrap;
}

@media (max-width: 640px) {
    .admin-supervisors .table-actions {
        flex-wrap: wrap; /* on small screens allow vertical stacking */
    }
}

.admin-supervisors .admin-table-section {
    display: grid;
    gap: 12px;
}

/* Allow horizontal scrolling for admin tables so action buttons are not clipped */
.admin-supervisors .table-wrapper {
    overflow: auto;
}

/* Allow admin tables to shrink below global min-width when container is small */
.admin-supervisors .table-wrapper table {
    min-width: 0;
    table-layout: auto;
}

.admin-supervisors .table-wrapper td,
.admin-supervisors .table-wrapper th {
    overflow: visible;
}

.admin-supervisors .admin-table-section h2 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text);
}

/* Ensure admin products page uses the same layout rules as admin-supervisors
   so the products table sits inside the .admin-table-section and does not
   overlap other content. This overrides global min-width rules for this
   page and keeps the table-wrapper flowing normally. */
.admin-products .admin-form-section {
    display: grid;
    gap: 16px;
}

.admin-products .admin-form {
    display: grid;
    gap: 20px;
    background: var(--surface-muted);
    border-radius: 16px;
    padding: 20px;
}

.admin-products .admin-form .form-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

@media (min-width: 980px) {
    .admin-products .admin-content {
        grid-template-columns: 420px 1fr;
        align-items: start;
    }

    .admin-products .admin-table-section .table-wrapper table {
        min-width: 0;
        table-layout: auto;
    }

    .admin-products .admin-table-section {
        display: block;
    }
}

.admin-products .admin-table-section {
    display: grid;
    gap: 12px;
}

.admin-products .table-wrapper {
    /* allow horizontal scrolling when necessary but keep element in flow */
    overflow: auto;
}

.admin-products .table-wrapper table {
    min-width: 0;
}
