/* ===== theme.css — shared design system: light green / black / white ===== */

:root {
    --green-900: #064e3b;
    --green-800: #065f46;
    --green-700: #047857;
    --green-600: #059669;
    --green-500: #10b981;
    --green-100: #d1fae5;
    --green-50: #ecfdf5;

    --ink-900: #0a0a0a;
    --ink-800: #171a19;
    --ink-700: #2b302e;
    --ink-100: #dde1df;

    --white: #ffffff;
    --surface: #fbfdfc;
    --card: rgba(255, 255, 255, .97);

    --text: #17251f;
    --muted: #6b7280;
    --border: #d9e2dd;

    --danger-bg: #fef2f2;
    --danger-border: #fecaca;
    --danger-text: #b91c1c;

    --shadow-card: 0 30px 80px rgba(10, 10, 10, .16), 0 8px 28px rgba(10, 10, 10, .08);
    --shadow-btn: 0 10px 24px rgba(5, 150, 105, .24);
    --shadow-btn-hover: 0 15px 32px rgba(5, 150, 105, .30);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body.theme-body {
    margin: 0;
    min-height: 100vh;
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 10% 10%, rgba(52, 211, 153, .24), transparent 28%),
        radial-gradient(circle at 90% 15%, rgba(16, 185, 129, .18), transparent 26%),
        linear-gradient(135deg, #f3fbf7 0%, #e8f7ef 50%, #dff5e8 100%);
    overflow-x: hidden;
}

/* ---------- Background decoration ---------- */
.bg-orb {
    position: fixed;
    border-radius: 999px;
    pointer-events: none;
    filter: blur(70px);
    z-index: 0;
}

.bg-orb.one { width: 320px; height: 320px; top: -130px; right: -90px; background: rgba(16, 185, 129, .20); }
.bg-orb.two { width: 300px; height: 300px; bottom: -130px; left: -80px; background: rgba(52, 211, 153, .18); }
.bg-orb.three {
    width: 180px; height: 180px; top: 48%; left: 49%;
    background: rgba(10, 10, 10, .06);
    transform: translate(-50%, -50%);
}

/* ---------- Popup shell / card ---------- */
.popup-shell {
    position: relative;
    z-index: 2;
    width: min(100%, 500px);
}

.popup-card {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .85);
    border-radius: 28px;
    background: var(--card);
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: popupIn .42s cubic-bezier(.16, 1, .3, 1);
}

@keyframes popupIn {
    from { opacity: 0; transform: translateY(24px) scale(.975); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Header ---------- */
.popup-header {
    position: relative;
    padding: 18px 22px 24px;
    overflow: hidden;
    color: white;
    text-align: center;
    background:
        radial-gradient(circle at 10% 0%, rgba(255, 255, 255, .12), transparent 28%),
        radial-gradient(circle at 100% 100%, rgba(16, 185, 129, .24), transparent 35%),
        linear-gradient(145deg, var(--ink-900), var(--green-900) 55%, var(--green-800));
}

.popup-header::before {
    content: "";
    position: absolute;
    width: 190px; height: 190px;
    border-radius: 50%;
    right: -85px; top: -100px;
    background: rgba(255, 255, 255, .05);
}

.popup-header::after {
    content: "";
    position: absolute;
    width: 150px; height: 150px;
    border-radius: 50%;
    left: -75px; bottom: -90px;
    background: rgba(16, 185, 129, .10);
}

.back-btn {
    position: relative;
    z-index: 4;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 11px 7px 8px;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 999px;
    color: rgba(255, 255, 255, .92);
    background: rgba(255, 255, 255, .08);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    transition: all .2s ease;
}

.back-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, .14);
    transform: translateX(-2px);
}

.back-btn svg { width: 15px; height: 15px; fill: currentColor; }

/* ---------- Logo ---------- */
.logo-zone {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 18px auto 16px;
    width: 100%;
}

.logo-box {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 150px;
    height: 76px;
    padding: 10px 16px;
    border: 1px solid rgba(255, 255, 255, .72);
    border-radius: 16px;
    background: rgba(255, 255, 255, .98);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .10), inset 0 0 0 1px rgba(255, 255, 255, .5);
}

.logo-box img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center;
}

.brand-title {
    position: relative;
    z-index: 3;
    margin: 0;
    font-size: 25px;
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: -.02em;
    color: white;
}

.brand-subtitle {
    position: relative;
    z-index: 3;
    margin: 7px 0 0;
    color: rgba(255, 255, 255, .76);
    font-size: 13px;
    line-height: 1.5;
}

/* ---------- Form ---------- */
.popup-form { padding: 24px 24px 26px; }

.form-intro {
    margin: 0 0 18px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.field { margin-bottom: 15px; }

.field label {
    display: block;
    margin: 0 0 7px 3px;
    color: #35443d;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .01em;
}

.control-wrap { position: relative; }

.field input,
.field select {
    display: block;
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 13px;
    outline: none;
    color: #17251f;
    background: #fbfdfc;
    font: inherit;
    font-size: 14px;
    transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

.field input::placeholder { color: #9ca3af; }

.field input:focus,
.field select:focus {
    border-color: var(--green-500);
    background: white;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, .12);
}

.field select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 42px;
    cursor: pointer;
    background-image:
        linear-gradient(45deg, transparent 50%, #047857 50%),
        linear-gradient(135deg, #047857 50%, transparent 50%);
    background-position: calc(100% - 18px) 20px, calc(100% - 12px) 20px;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}

.dynamic-field { overflow: hidden; }

[x-cloak] { display: none !important; }

/* Honeypot — visually hidden but present in the DOM/tab order avoided, not display:none */
.hp-field {
    position: absolute;
    left: -9999px;
    top: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* ---------- Messages ---------- */
.alert {
    margin-bottom: 16px;
    padding: 11px 13px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.45;
}

.alert-error {
    border: 1px solid var(--danger-border);
    background: var(--danger-bg);
    color: var(--danger-text);
}

/* ---------- Buttons ---------- */
.btn-primary {
    position: relative;
    display: inline-flex;
    width: 100%;
    min-height: 50px;
    align-items: center;
    justify-content: center;
    margin-top: 5px;
    padding: 13px 18px;
    border: 0;
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    color: white;
    text-decoration: none;
    background: linear-gradient(135deg, var(--green-800), var(--green-600));
    box-shadow: var(--shadow-btn);
    font-size: 14px;
    font-weight: 800;
    font-family: inherit;
    transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease;
}

.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--shadow-btn-hover); }
.btn-primary:active { transform: translateY(0); }

.btn-primary:disabled {
    cursor: not-allowed;
    opacity: .72;
    transform: none;
}

.btn-primary::after {
    content: "";
    position: absolute;
    inset: -80% -30%;
    background: linear-gradient(110deg, transparent 35%, rgba(255, 255, 255, .18) 46%, transparent 57%);
    transform: translateX(-40%);
    animation: shine 4.2s infinite;
    pointer-events: none;
}

@keyframes shine {
    0%, 55% { transform: translateX(-55%); }
    100% { transform: translateX(55%); }
}

.btn-secondary {
    display: inline-flex;
    width: 100%;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    padding: 12px 18px;
    border: 1.5px solid var(--ink-900);
    border-radius: 14px;
    background: transparent;
    color: var(--ink-900);
    text-decoration: none;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background .2s ease, color .2s ease, transform .2s ease;
}

.btn-secondary:hover { background: var(--ink-900); color: white; }

.btn-spinner {
    display: none;
    width: 15px;
    height: 15px;
    margin-right: 9px;
    border: 2px solid rgba(255, 255, 255, .5);
    border-top-color: white;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

.is-loading .btn-spinner { display: inline-block; }

@keyframes spin { to { transform: rotate(360deg); } }

.form-note {
    margin: 12px 0 0;
    text-align: center;
    color: #8b9590;
    font-size: 11px;
    line-height: 1.45;
}

/* ---------- Success checkmark ---------- */
.success-wrap {
    display: none;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 18px 6px 8px;
}

.success-wrap.is-visible { display: flex; }

.success-check { width: 84px; height: 84px; margin-bottom: 6px; }

.success-check .check-circle {
    stroke: var(--green-600);
    stroke-width: 3;
    stroke-dasharray: 152;
    stroke-dashoffset: 152;
    fill: none;
    animation: check-circle-draw .5s ease-out forwards;
}

.success-check .check-mark {
    stroke: var(--green-600);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    stroke-dasharray: 40;
    stroke-dashoffset: 40;
    animation: check-mark-draw .4s .45s ease-out forwards;
}

@keyframes check-circle-draw { to { stroke-dashoffset: 0; } }
@keyframes check-mark-draw { to { stroke-dashoffset: 0; } }

.success-wrap h2 {
    margin: 4px 0 6px;
    font-size: 21px;
    font-weight: 800;
    color: var(--ink-900);
}

.success-wrap p {
    margin: 0 0 18px;
    color: var(--muted);
    font-size: 13.5px;
    line-height: 1.55;
}

.success-wrap .btn-secondary { width: auto; padding: 10px 22px; min-height: 40px; }

/* ---------- PIN input ---------- */
.pin-inputs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 4px 0 20px;
}

.pin-box {
    width: 44px;
    height: 52px;
    border: 1.5px solid var(--ink-900);
    border-radius: 12px;
    text-align: center;
    font-size: 22px;
    font-weight: 800;
    color: var(--ink-900);
    background: var(--surface);
    transition: border-color .2s ease, box-shadow .2s ease;
}

.pin-box:focus {
    outline: none;
    border-color: var(--green-500);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, .15);
}

.lockout-note {
    margin-bottom: 16px;
    padding: 11px 13px;
    border: 1px solid #fde68a;
    border-radius: 12px;
    background: #fffbeb;
    color: #92400e;
    font-size: 13px;
    line-height: 1.45;
    text-align: center;
}

/* ---------- Admin shell ---------- */
.admin-body {
    display: block;
    min-height: 100vh;
    padding: 0;
    background: var(--surface);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    color: var(--text);
}

.admin-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 28px;
    background: linear-gradient(120deg, var(--ink-900), var(--ink-800));
    color: white;
    box-shadow: 0 6px 18px rgba(10, 10, 10, .18);
    flex-wrap: wrap;
}

.admin-nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-nav-logo {
    width: 42px;
    height: 42px;
    object-fit: contain;
    background: white;
    border-radius: 9px;
    padding: 4px;
}

.admin-nav h1 {
    margin: 0;
    font-size: 19px;
    font-weight: 800;
    letter-spacing: .01em;
    font-family: inherit;
}

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

.admin-nav .nav-link {
    font-size: 13px;
    font-weight: 600;
    color: white;
    text-decoration: none;
    padding: 9px 16px;
    border-radius: 10px;
    background: var(--green-700);
    transition: background .2s ease;
}

.admin-nav .nav-link:hover { background: var(--green-600); }

.admin-nav .logout-form button {
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, .85);
    background: transparent;
    border: 1px solid rgba(255, 255, 255, .3);
    padding: 8px 15px;
    border-radius: 10px;
    cursor: pointer;
    transition: all .2s ease;
}

.admin-nav .logout-form button:hover { background: rgba(255, 255, 255, .12); color: white; }

.admin-wrap {
    max-width: 1120px;
    margin: 0 auto;
    padding: 28px 20px 48px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 22px;
}

.stat-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px 18px;
    box-shadow: 0 6px 18px rgba(10, 10, 10, .05);
}

.stat-card .stat-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
}

.stat-card .stat-value {
    margin-top: 6px;
    font-size: 28px;
    font-weight: 800;
    color: var(--ink-900);
}

.admin-panel {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(10, 10, 10, .08);
    border: 1px solid var(--border);
    overflow: hidden;
}

.admin-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    background: var(--green-50);
}

.admin-panel-head h2 {
    margin: 0;
    font-size: 17px;
    font-weight: 800;
    color: var(--ink-900);
}

.admin-panel-head p {
    margin: 3px 0 0;
    font-size: 13px;
    color: var(--muted);
}

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

.badge-pill {
    font-size: 11.5px;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--green-100);
    color: var(--green-900);
}

.csv-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 10px;
    background: var(--ink-900);
    color: white;
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    transition: background .2s ease;
}

.csv-btn:hover { background: var(--green-700); }

/* Search */
.search-form {
    display: flex;
    gap: 8px;
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.search-form input[type="text"] {
    flex: 1 1 220px;
    min-height: 42px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 11px;
    font: inherit;
    font-size: 13.5px;
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.search-form input[type="text"]:focus {
    border-color: var(--green-500);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, .12);
}

.search-form select {
    min-height: 42px;
    padding: 10px 34px 10px 14px;
    border: 1px solid var(--border);
    border-radius: 11px;
    font: inherit;
    font-size: 13.5px;
    color: var(--text);
    background: #fbfdfc;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, #047857 50%),
        linear-gradient(135deg, #047857 50%, transparent 50%);
    background-position: calc(100% - 18px) 18px, calc(100% - 12px) 18px;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.search-form select:focus {
    border-color: var(--green-500);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, .12);
}

.search-form button {
    padding: 10px 20px;
    border: 0;
    border-radius: 11px;
    background: var(--ink-900);
    color: white;
    font: inherit;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    transition: background .2s ease;
}

.search-form button:hover { background: var(--green-700); }

.search-form a.clear-link {
    display: inline-flex;
    align-items: center;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
}

.search-form a.clear-link:hover { color: var(--ink-900); }

/* Table */
.table-scroll { overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; text-align: left; }

.data-table thead th {
    padding: 14px 22px;
    background: var(--ink-900);
    color: rgba(255, 255, 255, .88);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    white-space: nowrap;
}

.data-table tbody td {
    padding: 15px 22px;
    border-bottom: 1px solid var(--border);
    font-size: 14.5px;
    color: var(--text);
    vertical-align: top;
}

.data-table tbody tr:hover { background: var(--green-50); }

.data-table .id-cell { color: var(--muted); font-weight: 600; }
.data-table .name-cell { font-weight: 700; color: var(--ink-900); }
.data-table .loc-pill {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--green-50);
    border: 1px solid var(--green-100);
    color: var(--green-900);
    font-size: 12px;
    font-weight: 600;
}
.data-table .time-cell {
    white-space: nowrap;
    display: table-cell;
}

.data-table .time-cell .time-date {
    display: block;
    color: var(--text);
    font-size: 13.5px;
    font-weight: 600;
}

.data-table .time-cell .time-time {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}
.data-table .empty-row { text-align: center; padding: 44px 20px; color: #9aa39d; }

.row-label { display: none; font-weight: 700; color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 16px 22px;
    border-top: 1px solid var(--border);
}

.pagination .page-info { font-size: 12.5px; color: var(--muted); }

.pagination .page-links { display: flex; gap: 6px; flex-wrap: wrap; }

.pagination a,
.pagination span.page-current {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border-radius: 9px;
    font-size: 12.5px;
    font-weight: 700;
    text-decoration: none;
    border: 1.5px solid var(--ink-900);
    color: var(--ink-900);
    transition: background .2s ease, color .2s ease;
}

.pagination a:hover { background: var(--ink-900); color: white; }

.pagination span.page-current {
    background: var(--green-700);
    border-color: var(--green-700);
    color: white;
}

.pagination .page-disabled {
    opacity: .35;
    pointer-events: none;
}

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
    body.theme-body { padding: 14px; align-items: flex-start; }
    .popup-shell { margin: 8px auto; }
    .popup-card { border-radius: 22px; }
    .popup-header { padding: 15px 16px 21px; }
    .logo-zone { margin-top: 16px; margin-bottom: 14px; }
    .logo-box { width: 130px; height: 66px; padding: 8px 12px; border-radius: 13px; }
    .brand-title { font-size: 21px; }
    .brand-subtitle { font-size: 12px; }
    .popup-form { padding: 20px 17px 22px; }
    .pin-box { width: 38px; height: 46px; font-size: 19px; }
}

@media (max-width: 380px) {
    .logo-box { width: 112px; height: 58px; padding: 7px 10px; }
    .brand-title { font-size: 19px; }
    .back-btn { font-size: 11px; }
    .pin-box { width: 33px; height: 42px; font-size: 17px; }
}

@media (max-width: 900px) {
    .stat-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
    .stat-card { padding: 13px 14px; }
    .stat-card .stat-value { font-size: 21px; }
}

@media (max-width: 640px) {
    .admin-nav { padding: 12px 16px; }
    .admin-nav-logo { width: 34px; height: 34px; }
    .admin-nav h1 { font-size: 15.5px; }
    .admin-wrap { padding: 18px 12px 36px; }
    .stat-grid { grid-template-columns: 1fr; }
    .panel-head-actions { width: 100%; justify-content: space-between; }
    .search-form { flex-direction: column; align-items: stretch; }
    .search-form input[type="text"],
    .search-form select,
    .search-form button,
    .search-form a.clear-link { width: 100%; flex: 1 1 auto; }

    /* Card-view table for narrow screens instead of horizontal scroll */
    .data-table thead { display: none; }
    .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
    .data-table tbody tr {
        margin: 12px;
        border: 1px solid var(--border);
        border-radius: 14px;
        overflow: hidden;
        box-shadow: 0 4px 14px rgba(10, 10, 10, .05);
    }
    .data-table tbody td { border-bottom: 1px solid var(--border); padding: 10px 16px; }
    .data-table tbody td:last-child { border-bottom: 0; }
    .row-label { display: block; }
    .pagination { flex-direction: column; align-items: stretch; text-align: center; }
    .pagination .page-links { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }
}
