:root {
    --bg: #0f1115;
    --panel: #161a20;
    --panel2: #12161b;
    --text: #e9edf3;
    --muted: #a8b0bb;
    --border: #2a313b;

    --accent: #a7d9a7;
    --accentBorder: rgba(167, 217, 167, .55);
    --accentBg: rgba(167, 217, 167, .18);

    --danger: #ff6b6b;
    --dangerBorder: rgba(255, 107, 107, .45);
    --dangerBg: rgba(255, 107, 107, .12);

    --shadow: 0 10px 24px rgba(0, 0, 0, .35);
    --radius: 16px;

    --bottom-nav-height: 64px;
    --sticky-top-offset: 0px;
}

* {
    box-sizing: border-box;
    max-width: 100%;
}

html,
body {
    height: 100%;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

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

a:hover {
    text-decoration: underline;
}

.wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 16px;
}

.has-nav .wrap {
    padding-bottom: calc(var(--bottom-nav-height) + 12px);
}

h1 {
    margin: 0;
    font-size: 26px;
    letter-spacing: .2px;
}

.sub {
    margin: .25rem 0 0;
    color: var(--muted);
}

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

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.filters {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    align-items: end;
}

.filters-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.sortbar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: end;
}

.sortdir .btn {
    min-width: 72px;
}

.card {
    background: linear-gradient(180deg, var(--panel), var(--panel2));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px;
    margin-bottom: 14px;
}

.flash {
    background: #1a212b;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 12px;
    border-radius: 12px;
    margin: 10px 0;
}

.flash.error {
    border-color: var(--dangerBorder);
    color: var(--danger);
}

label {
    display: block;
    font-size: 12px;
    color: var(--accent);
    margin: 12px 0 6px;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="date"],
input[type="tel"],
textarea,
select {
    width: 100%;
    background: #0f1318;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 12px;
    outline: none;
}

textarea {
    min-height: 90px;
    resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--accentBorder);
    box-shadow: 0 0 0 3px rgba(167, 217, 167, .15);
}

.row3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.row2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.btn {
    border: 1px solid var(--border);
    background: #121821;
    color: var(--text);
    padding: 10px 14px;
    border-radius: 999px;
    cursor: pointer;
}

.btn:hover {
    border-color: rgba(167, 217, 167, .35);
}

.btn.primary {
    background: var(--accentBg);
    border-color: var(--accentBorder);
}

.btn.primary:hover {
    background: rgba(167, 217, 167, .24);
}

.btn.danger {
    background: var(--dangerBg);
    border-color: var(--dangerBorder);
    color: var(--danger);
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    height: 40px;
    padding: 0 14px;
    font-size: 14px;
}

.actions button.btn {
    font: inherit;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 10px;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

th {
    text-align: left;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    padding: 0 10px 6px;
}

td {
    background: #11161d;
    border: 1px solid var(--border);
    padding: 10px;
    vertical-align: top;
}

tr td:first-child {
    border-top-left-radius: 12px;
    border-bottom-left-radius: 12px;
}

tr td:last-child {
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
}

th.sortable {
    cursor: pointer;
    user-select: none;
}

th.sortable:hover {
    color: var(--text);
}

.sort-ind {
    display: inline-block;
    margin-left: 6px;
    font-size: 11px;
    opacity: 0.8;
}

.seg {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.seg input {
    display: none;
}

.seg label {
    margin: 0;
    border: 1px solid var(--border);
    background: #121821;
    color: var(--text);
    padding: 12px 14px;
    border-radius: 12px;
    cursor: pointer;
    min-width: 120px;
    text-align: center;
}

.seg input:checked+label {
    background: var(--accentBg);
    border-color: var(--accentBorder);
}

.mobile-only {
    display: none;
}

.desktop-only {
    display: block;
}

.item-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.item-title {
    font-size: 18px;
    font-weight: 700;
}

.item-sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

details>summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
    color: var(--muted);
    margin-top: 10px;
}

details>summary::-webkit-details-marker {
    display: none;
}

.sticky-actions {
    position: sticky;
    bottom: 0;
    background: linear-gradient(180deg, rgba(15, 17, 21, 0), rgba(15, 17, 21, 1) 30%);
    padding-top: 12px;
}

.sticky-actions .actions {
    justify-content: space-between;
}

.wrap,
.card,
.info-panel,
.modal,
.bottom-nav {
    max-width: 100%;
}

.info-panel,
.card,
td,
th,
.item-title,
.item-sub {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* =========================
   Users admin list
   ========================= */

.users-topbar {
    align-items: center;
}

.users-table-wrap {
    display: block;
}

.users-cards {
    display: none;
}

.users-table td,
.users-table th {
    vertical-align: middle;
}

.users-name {
    font-weight: 700;
}

.users-actions-nowrap {
    flex-wrap: nowrap;
}

.users-actions-nowrap form {
    margin: 0;
}

.users-card-list {
    display: grid;
    gap: 12px;
}

.users-user-card {
    margin-bottom: 0;
    padding: 14px;
}

.users-card-name {
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.3;
    margin-bottom: 10px;
}

.users-active-text {
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.users-active-text.is-active {
    color: var(--accent);
}

.users-active-text.is-inactive {
    color: var(--muted);
}

.users-meta {
    margin-top: 12px;
    display: grid;
    gap: 10px;
}

.users-meta-row {
    display: grid;
    grid-template-columns: 84px 1fr;
    gap: 10px;
    align-items: start;
}

.users-meta-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.users-meta-value {
    color: var(--text);
    font-size: 0.95rem;
    word-break: break-word;
}

.users-card-actions {
    margin-top: 12px;
}

.users-card-actions form {
    margin: 0;
}

/* =========================
   Users form
   ========================= */

.users-form {
    margin-top: 6px;
}

.form-field {
    margin-bottom: 10px;
}

.form-help {
    margin-top: 6px;
}

.form-back-link {
    margin-bottom: 0;
    margin-top: 12px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
}

.checkbox-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: #7f8a98;
    flex: 0 0 auto;
}

.checkbox-label {
    margin: 0;
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
}

/* =========================
   People list / search
   ========================= */

.people-name-search-card {
    padding: 10px 12px;
}

.date-filter-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.date-picker-shadow {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.picker-hitbox {
    position: relative;
    width: 40px;
    min-width: 40px;
    flex: 0 0 40px;
}

.native-picker-hitbox-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    pointer-events: auto;
    z-index: 2;
    appearance: none;
    -webkit-appearance: none;
    padding: 0;
    margin: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.native-picker-hitbox-input::-webkit-calendar-picker-indicator {
    opacity: 0;
    display: block;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.native-picker-hitbox-input:focus {
    box-shadow: none;
    outline: none;
}

.picker-hitbox-btn {
    width: 40px;
    min-width: 40px;
    padding: 0;
    flex: 0 0 40px;
    text-decoration: none;
    color: var(--accent);
    position: relative;
    z-index: 1;
    pointer-events: none;
}

.picker-hitbox-btn:hover {
    text-decoration: none;
    color: var(--accent);
}

.picker-hitbox-icon {
    color: currentColor;
    font-size: 18px;
    line-height: 1;
}

/* =========================
   People form
   ========================= */

.people-form-header {
    position: sticky;
    top: var(--sticky-top-offset);
    z-index: 50;
    margin-bottom: 14px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: linear-gradient(180deg, rgba(22, 26, 32, 0.96), rgba(18, 22, 27, 0.96));
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
}

.people-form-header .topbar {
    margin-bottom: 0;
}

.people-form-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.people-form-title-sep {
    color: var(--muted);
    font-weight: 700;
}

.people-form-main {
    margin-top: 0;
}

.people-form-actions {
    margin-top: 14px;
}

.people-danger-actions {
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.people-danger-actions form {
    margin: 0;
}

.people-record-key {
    font-size: 11px;
    line-height: 1.2;
    text-align: right;
}

.people-phone-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.people-phone-input {
    min-width: 0;
    flex: 1 1 auto;
}

.people-phone-call-btn {
    display: none;
    width: 40px;
    min-width: 40px;
    padding: 0;
    flex: 0 0 40px;
    text-decoration: none;
    color: var(--accent);
}

.people-phone-call-btn:hover {
    text-decoration: none;
    color: var(--accent);
}

.people-phone-call-icon {
    color: currentColor;
    font-size: 18px;
    line-height: 1;
}

.people-phone-call-btn.is-disabled {
    opacity: 0.45;
    pointer-events: none;
}

/* =========================
   Bottom footer nav (fixed)
   ========================= */

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--bottom-nav-height);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    z-index: 9999;
    background: rgba(15, 17, 21, 0.92);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(10px);
}

.bottom-nav .nav-inner {
    width: min(900px, 100%);
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
}

.bottom-nav .nav-buttons {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 10px;
}

.bottom-nav a.nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    text-decoration: none;
    font-weight: 800;
    letter-spacing: .2px;
}

.bottom-nav a.nav-btn:hover {
    background: rgba(255, 255, 255, 0.07);
    text-decoration: none;
}

.bottom-nav button.info-btn {
    height: 32px;
    width: 32px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    cursor: pointer;
    font-weight: 900;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.bottom-nav button.info-btn:hover {
    background: rgba(255, 255, 255, 0.07);
}

.info-panel {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--bottom-nav-height) + 10px);
    max-width: 1100px;
    margin: 0 auto;
    background: rgba(45, 92, 165, 0.20);
    border: 1px solid rgba(90, 150, 240, 0.55);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(90, 150, 240, 0.18);
    border-radius: 12px;
    padding: 10px 12px;
    backdrop-filter: blur(10px);
    z-index: 9998;
    font-size: 12px;
    color: var(--text);
}

.info-panel .muted {
    color: var(--muted);
}

.info-panel[hidden] {
    display: none;
}

.info-actions {
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.info-actions form {
    margin: 0;
}

.btn-logout {
    padding: 8px 12px;
    font-size: 12px;
}

/* =========================
   Modal (Search popup)
   ========================= */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 12px;
}

.modal {
    position: fixed;
    z-index: 10001;
    top: 12px;
    bottom: auto;
    left: 12px;
    right: 12px;
    max-width: 900px;
    margin: 0 auto;
    max-height: calc(100vh - 24px);
    background: linear-gradient(180deg, var(--panel), var(--panel2));
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    transform: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal[hidden],
.modal-overlay[hidden] {
    display: none;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 12px 12px 0 12px;
    flex: 0 0 auto;
}

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

.modal-actions {
    flex: 0 0 auto;
    display: flex;
    gap: 10px;
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: linear-gradient(180deg, rgba(18, 22, 27, 0.96), rgba(15, 17, 21, 0.98));
}

.modal-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    height: 40px;
    padding: 0 14px;
    font-size: 14px;
}

.modal-actions-split {
    justify-content: space-between;
    align-items: center;
}

.modal-actions-split .actions {
    justify-content: flex-end;
}

/* =========================
   Responsive
   ========================= */

@media (max-width: 900px) {

    .row3,
    .row2 {
        grid-template-columns: 1fr;
    }

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

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

    .filters-actions {
        justify-content: flex-start;
    }

    .sortbar {
        grid-template-columns: 1fr auto;
    }

    .desktop-only {
        display: none;
    }

    .mobile-only {
        display: block;
    }

    .users-topbar .actions {
        width: 100%;
    }

    .users-topbar .actions .btn {
        width: 100%;
    }

    .users-table-wrap {
        display: none;
    }

    .users-cards {
        display: block;
    }

    .users-card-actions .btn,
    .users-card-actions form,
    .users-card-actions form .btn {
        width: 100%;
    }

    .users-card-actions form {
        display: block;
    }

    .users-meta-row {
        grid-template-columns: 72px 1fr;
    }

    .people-form-header {
        padding: 10px 12px;
    }

    .people-danger-actions {
        align-items: flex-start;
    }

    .people-record-key {
        text-align: left;
    }

    .people-phone-call-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .modal-actions-split {
        flex-direction: column;
        align-items: stretch;
    }

    .modal-actions-split>.btn,
    .modal-actions-split .actions,
    .modal-actions-split .actions .btn {
        width: 100%;
    }

    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="date"],
    input[type="tel"],
    textarea,
    select {
        font-size: 16px;
    }

    .seg label {
        min-width: 0;
        flex: 1 1 auto;
    }
}