/*
 * assets/css/style.css
 * ธีมหลักของระบบ AOC NPT2 — พื้นหลังไล่เฉดม่วง-ชมพูพร้อมแสงโบเก้ (bokeh)
 * ใช้ร่วมกันทุกหน้าทั้งระบบ, การ์ด/ป้าย/ปุ่มทั้งหมดอิงจากตัวแปรสีด้านล่าง
 */

:root {
    /* พื้นหลังไล่เฉด: สว่าง (ชมพู-ม่วง) ด้านบน -> เข้ม (กรมท่า-ม่วง) ด้านล่าง ตามภาพตัวอย่าง */
    --bg-grad-1: #e26cff;
    --bg-grad-2: #c15fe0;
    --bg-grad-3: #9a4dc4;
    --bg-grad-4: #7b3aa8;
    --bg-grad-5: #5c2f86;
    --bg-grad-6: #402868;
    --bg-grad-7: #241c40;
    --bg-grad-8: #171325;
    --bg-bottom: #14101f;

    --card-bg: rgba(40, 24, 62, 0.78);
    --card-bg-solid: #241735;
    --panel-bg: rgba(24, 14, 38, 0.5);
    --border: rgba(199, 165, 230, 0.22);
    --input-bg: rgba(20, 12, 33, 0.65);
    --text: #f4eefc;
    --text-dim: #c6b3e0;
    --accent: #a855f7;
    --accent-hover: #9333ea;
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.15);
    --radius: 12px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'Sarabun', 'Segoe UI', sans-serif;
    color: var(--text);
    background-color: var(--bg-bottom);
    background-repeat: no-repeat;
    background-attachment: fixed;
    /* แสงโบเก้ (bokeh) กระจายทั่วพื้นหลัง ซ้อนบนไล่เฉดหลัก ให้ตรงกับภาพตัวอย่าง */
    background-image:
        radial-gradient(circle 90px at 6% 86%, rgba(255,255,255,0.16) 0%, rgba(216,178,245,0.10) 55%, transparent 75%),
        radial-gradient(circle 46px at 17% 94%, rgba(255,255,255,0.20) 0%, transparent 72%),
        radial-gradient(circle 60px at 27% 82%, rgba(216,178,245,0.22) 0%, transparent 74%),
        radial-gradient(circle 34px at 9% 68%, rgba(255,255,255,0.16) 0%, transparent 72%),
        radial-gradient(circle 70px at 40% 90%, rgba(216,178,245,0.20) 0%, transparent 74%),
        radial-gradient(circle 30px at 52% 80%, rgba(255,255,255,0.16) 0%, transparent 72%),
        radial-gradient(circle 95px at 88% 88%, rgba(216,178,245,0.20) 0%, transparent 75%),
        radial-gradient(circle 42px at 96% 70%, rgba(255,255,255,0.18) 0%, transparent 72%),
        radial-gradient(circle 55px at 75% 94%, rgba(216,178,245,0.20) 0%, transparent 74%),
        radial-gradient(circle 26px at 63% 62%, rgba(255,255,255,0.14) 0%, transparent 70%),
        radial-gradient(circle 20px at 85% 40%, rgba(255,255,255,0.12) 0%, transparent 70%),
        radial-gradient(circle 16px at 12% 30%, rgba(255,255,255,0.10) 0%, transparent 70%),
        radial-gradient(circle 2px at 20% 18%, rgba(255,255,255,0.85) 0%, transparent 100%),
        radial-gradient(circle 2px at 62% 12%, rgba(255,255,255,0.75) 0%, transparent 100%),
        radial-gradient(circle 2px at 45% 34%, rgba(255,255,255,0.7) 0%, transparent 100%),
        radial-gradient(circle 2px at 80% 22%, rgba(255,255,255,0.8) 0%, transparent 100%),
        radial-gradient(circle 2px at 30% 46%, rgba(255,255,255,0.6) 0%, transparent 100%),
        radial-gradient(circle 2px at 92% 52%, rgba(255,255,255,0.65) 0%, transparent 100%),
        linear-gradient(180deg,
            var(--bg-grad-1) 0%,
            var(--bg-grad-2) 12%,
            var(--bg-grad-3) 28%,
            var(--bg-grad-4) 42%,
            var(--bg-grad-5) 58%,
            var(--bg-grad-6) 72%,
            var(--bg-grad-7) 86%,
            var(--bg-grad-8) 100%);
}

/* ---------- Auth pages (login / register) ---------- */

body.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 480px;
    background: var(--card-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: 0 20px 60px rgba(20, 8, 40, 0.35);
}

.auth-card h1 {
    margin: 0 0 4px;
    font-size: 1.5rem;
}

.auth-sub {
    margin: 0 0 24px;
    color: var(--text-dim);
    font-size: 0.9rem;
}

.form-group {
    margin-bottom: 18px;
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group {
    flex: 1;
    min-width: 0;
}

/* B8: กล่องฟิลด์เฉพาะเคสภัยออนไลน์ — แสดง/ซ่อนด้วย JS ตามหมวดหมู่ที่เลือก */
.form-group-box {
    margin-bottom: 18px;
    padding: 14px 16px;
    border: 1px solid var(--border, #ddd);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.02);
}

label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.req {
    color: var(--danger);
}

input,
select {
    width: 100%;
    padding: 12px 14px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
}

input::placeholder,
textarea::placeholder {
    color: #8a76ab;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
}

select option {
    background: var(--card-bg-solid);
    color: var(--text);
}

.hint {
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--text-dim);
    background: rgba(168, 85, 247, 0.1);
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 8px;
    padding: 10px 12px;
}

.btn-primary {
    width: 100%;
    padding: 13px;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}

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

.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 0.9rem;
    color: var(--text-dim);
}

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

.alert {
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
    font-size: 0.88rem;
}

.alert-error {
    background: var(--danger-bg);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fca5a5;
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.35);
    color: #86efac;
}

.alert ul {
    margin: 0;
    padding-left: 18px;
}

@media (max-width: 480px) {
    .form-row {
        flex-direction: column;
    }
}

/* ---------- Login: split layout (แนะนำระบบ + THACHIN Model ซ้าย / ฟอร์มเข้าสู่ระบบ ขวา) ---------- */

.login-grid {
    display: flex;
    align-items: stretch;
    gap: 44px;
    width: 100%;
    max-width: 1180px;
}

.login-hero {
    flex: 1 1 560px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 20px;
    padding-block: 12px;
}

.login-grid .auth-card {
    flex: 0 0 420px;
    align-self: center;
    margin: 0;
}

@media (max-width: 900px) {
    .login-grid {
        flex-direction: column;
        gap: 28px;
        max-width: 560px;
    }
    .login-hero {
        padding-block: 0;
    }
    .login-grid .auth-card {
        flex: none;
        width: 100%;
    }
}

.hero-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.hero-shield {
    flex: none;
    width: 54px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--card-bg-solid);
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--accent);
}

.hero-shield img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero-brand-text .eyebrow {
    margin: 0;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.hero-brand-text .org-name {
    margin: 2px 0 0;
    font-size: 0.82rem;
    color: var(--text-dim);
}

/* --- THACHIN Model card --- */

.thachin-card {
    background: var(--card-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
}

.thachin-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.thachin-badge {
    display: inline-block;
    padding: 5px 14px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.thachin-caption {
    font-size: 0.78rem;
    color: var(--text-dim);
    text-align: right;
}

.thachin-body {
    display: flex;
    align-items: center;
    gap: 22px;
    flex-wrap: wrap;
}

.wheel {
    position: relative;
    flex: none;
    width: 168px;
    height: 168px;
    border-radius: 50%;
    margin-inline: auto;
}

.wheel::before {
    content: "";
    position: absolute;
    inset: 8px;
    border-radius: 50%;
    border: 1px solid rgba(244, 238, 252, 0.35);
}

.wheel-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    font-size: 0.95rem;
    font-weight: 700;
    color: #1c1030;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
}

.wheel-label span {
    margin-top: 20px;
}

.wheel-center {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 66px;
    height: 66px;
    border-radius: 50%;
    background: var(--card-bg-solid);
    border: 2px solid var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.66rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--text);
}

.thachin-legend {
    flex: 1 1 220px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 9px 16px;
}

.thachin-legend-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.8rem;
}

.thachin-legend-num {
    flex: none;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.62rem;
    font-weight: 700;
    color: #1c1030;
    margin-top: 1px;
}

.thachin-legend-item b {
    display: block;
    font-size: 0.82rem;
}

.thachin-legend-item .th {
    color: var(--text-dim);
    font-size: 0.76rem;
}

/* --- status pill --- */

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    align-self: flex-start;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.35);
    color: #86efac;
    font-size: 0.78rem;
    font-weight: 600;
}

.status-pill .pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6);
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%   { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.55); }
    70%  { box-shadow: 0 0 0 7px rgba(74, 222, 128, 0); }
    100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

/* --- hero title / copy --- */

.hero-title {
    margin: 0;
    font-size: clamp(2rem, 4vw, 2.7rem);
    line-height: 1.1;
    font-weight: 700;
}

.hero-title .accent-text {
    color: var(--accent);
}

.hero-subtitle {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
}

.hero-org {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-dim);
}

.hero-desc {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.7;
    color: var(--text-dim);
    max-width: 62ch;
}

.hero-desc strong {
    color: var(--accent);
    font-weight: 700;
}

/* --- emergency SOS bar --- */

.sos-cta {
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    background: var(--danger-bg);
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: var(--radius);
    padding: 14px 18px;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.sos-cta:hover {
    background: rgba(239, 68, 68, 0.22);
    border-color: rgba(239, 68, 68, 0.6);
    transform: translateY(-1px);
}

.sos-cta-icon {
    flex: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.18);
    color: #fca5a5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sos-cta-text {
    flex: 1;
    min-width: 0;
}

.sos-cta-text .sos-eyebrow {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: #fca5a5;
}

.sos-cta-text .sos-main {
    display: block;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    margin-top: 2px;
}

.sos-cta-text .sos-sub {
    display: block;
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-top: 1px;
}

.sos-cta-chevron {
    flex: none;
    font-size: 1.3rem;
    color: #fca5a5;
}

@media (max-width: 480px) {
    .thachin-body {
        justify-content: center;
        text-align: left;
    }
}

/* ---------- Signed-in pages (dashboard / admin lists) — sidebar navigation ---------- */

/* .sidebar (<aside>) มาจาก views/partials/sidebar.php ซึ่งอยู่นอก .app-shell
   ในซอร์ส (เป็น sibling ก่อนหน้า ไม่ใช่ลูก) — เลยใช้ position: fixed แทนการพึ่ง
   flexbox ของ .app-shell เพื่อไม่ต้องพึ่งลำดับ DOM ที่แน่นอน แล้วดัน .main-content
   ด้วย margin-left เท่ากับความกว้าง sidebar แทน */
.app-shell {
    min-height: 100vh;
}

.sidebar {
    width: 264px;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, rgba(64, 32, 100, 0.94) 0%, rgba(36, 20, 58, 0.96) 55%, rgba(18, 10, 30, 0.98) 100%);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid var(--border);
    z-index: 40;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 20px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
}

.sidebar-brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--card-bg-solid);
    border: 1px solid var(--border);
    box-shadow: 0 4px 14px rgba(168, 85, 247, 0.25);
    flex-shrink: 0;
}

.sidebar-brand-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.35;
    min-width: 0;
}

.sidebar-brand-text strong {
    font-size: 1.02rem;
    letter-spacing: .2px;
}

.sidebar-brand-text small {
    color: var(--text-dim);
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .09em;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-section-label {
    margin: 16px 10px 6px;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--text-dim);
    opacity: .72;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: .92rem;
    font-weight: 500;
    position: relative;
    transition: background .15s ease, color .15s ease;
}

.sidebar-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: .85;
}

.sidebar-link:hover {
    background: rgba(168, 85, 247, 0.14);
    color: var(--text);
}

.sidebar-link.active {
    background: rgba(168, 85, 247, 0.24);
    color: #fff;
}

.sidebar-link.active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 8px;
    bottom: 8px;
    width: 4px;
    background: linear-gradient(180deg, #e26cff, var(--accent));
    border-radius: 0 4px 4px 0;
}

.sidebar-link.active svg {
    opacity: 1;
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 14px 12px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text);
    transition: background .15s ease;
}

.sidebar-user:hover {
    background: rgba(255, 255, 255, 0.06);
}

.sidebar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e26cff, var(--accent-hover));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .85rem;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
}

.sidebar-user-info strong {
    font-size: .85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-info small {
    font-size: .72rem;
    color: var(--text-dim);
}

.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 8px;
    border-radius: 10px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: .86rem;
    transition: background .15s ease, color .15s ease;
}

.sidebar-logout svg {
    width: 16px;
    height: 16px;
}

.sidebar-logout:hover {
    background: rgba(239, 68, 68, 0.14);
    color: #fca5a5;
}

.sidebar-toggle {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 60;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(24, 14, 38, 0.9);
    backdrop-filter: blur(10px);
    color: var(--text);
    cursor: pointer;
}

.sidebar-toggle svg {
    width: 20px;
    height: 20px;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 6, 18, 0.6);
    z-index: 45;
}

.sidebar-backdrop.show {
    display: block;
}

.main-content {
    margin-left: 264px;
    min-height: 100vh;
}

@media (max-width: 900px) {
    .sidebar-toggle {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform .22s ease;
        box-shadow: 8px 0 30px rgba(0, 0, 0, 0.4);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding-top: 60px;
    }
}

.page-wrap {
    max-width: 1100px;
    margin: 24px auto;
    padding: 28px 24px;
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.page-wrap h1 {
    margin: 0 0 8px;
    font-size: 1.4rem;
}

@media (max-width: 480px) {
    .page-wrap {
        margin: 12px;
        padding: 20px 16px;
    }
}

.text-dim {
    color: var(--text-dim);
    font-size: 0.85rem;
}

.btn-inline {
    display: inline-block;
    width: auto;
    text-decoration: none;
    padding: 10px 18px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 16px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    background: var(--card-bg);
}

.table th,
.table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    white-space: nowrap;
}

.table td:nth-child(5) {
    white-space: normal;
    min-width: 200px;
}

.table th {
    color: var(--text-dim);
    font-weight: 600;
    font-size: 0.8rem;
}

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

.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.inline-form select {
    width: auto;
    min-width: 160px;
}

.btn-small {
    width: auto;
    padding: 8px 14px;
    font-size: 0.85rem;
    margin-top: 0;
}

.btn-danger {
    width: auto;
    padding: 8px 14px;
    font-size: 0.85rem;
    background: var(--danger);
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-secondary {
    width: auto;
    padding: 10px 16px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    white-space: nowrap;
}

.btn-secondary:hover {
    border-color: var(--accent);
}

textarea {
    width: 100%;
    padding: 12px 14px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
}

textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.checkbox-label {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    font-size: 0.88rem;
    color: var(--text-dim);
    cursor: pointer;
}

.checkbox-label input {
    width: auto;
    margin-top: 3px;
}

/* ---------- Public SOS page ---------- */

body.sos-page {
    margin: 0;
    padding-bottom: 90px; /* กันแถบสายด่วนค้างท้ายจอบัง */
}

.sos-wrap {
    max-width: 620px;
    margin: 24px auto;
    padding: 28px 20px;
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

@media (max-width: 480px) {
    .sos-wrap {
        margin: 12px;
        padding: 20px 16px;
    }
}

.sos-header h1 {
    margin: 0 0 4px;
    font-size: 1.6rem;
}

.sos-track-link {
    font-size: 0.9rem;
    color: var(--text-dim);
}

.sos-track-link a {
    color: var(--accent);
}

.sos-back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
    padding: 7px 14px 7px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-dim);
    font-size: 0.85rem;
    text-decoration: none;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.sos-back-link:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.sos-form-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.sos-form-actions .btn-primary {
    margin-top: 0;
}

.sos-cancel-btn {
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    text-decoration: none;
    display: inline-block;
}

.anon-toggle-box {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 24px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 28px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    inset: 0;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    transition: 0.2s;
}

.switch-slider::before {
    content: "";
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    top: 3px;
    background: var(--text-dim);
    border-radius: 50%;
    transition: 0.2s;
}

.switch input:checked + .switch-slider {
    background: rgba(168, 85, 247, 0.35);
    border-color: var(--accent);
}

.switch input:checked + .switch-slider::before {
    transform: translateX(20px);
    background: var(--accent);
}

.severity-group {
    display: flex;
    gap: 10px;
}

.severity-option {
    flex: 1;
    text-align: center;
    padding: 12px 8px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
}

.severity-option input {
    display: none;
}

.severity-option small {
    color: var(--text-dim);
}

.severity-option:has(input:checked) {
    border-color: var(--accent);
    background: rgba(168, 85, 247, 0.16);
}

.location-row {
    display: flex;
    gap: 10px;
}

.location-row input {
    flex: 1;
}

.hotline-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    align-items: center;
    background: rgba(18, 10, 30, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    padding: 12px 20px;
    z-index: 10;
}

.hotline-label {
    font-weight: 600;
    font-size: 0.85rem;
}

.hotline-item {
    color: #fca5a5;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.hotline-item:hover {
    text-decoration: underline;
}

/* ---------- Success / tracking code screen ---------- */

.success-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.success-card {
    max-width: 480px;
    width: 100%;
    text-align: center;
    background: var(--card-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 32px;
    box-shadow: 0 20px 60px rgba(20, 8, 40, 0.35);
}

.success-icon {
    font-size: 3rem;
    margin-bottom: 8px;
}

.tracking-label {
    margin-top: 24px;
    color: var(--text-dim);
    font-size: 0.85rem;
}

.tracking-code {
    font-size: 2.4rem;
    font-weight: 700;
    letter-spacing: 8px;
    background: var(--input-bg);
    border: 1px dashed var(--accent);
    border-radius: 10px;
    padding: 14px;
    margin: 10px 0 16px;
}

/* ---------- Track status ---------- */

.status-badge {
    display: inline-block;
    margin-top: 14px;
    padding: 8px 16px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.9rem;
    background: rgba(168, 85, 247, 0.18);
    border: 1px solid rgba(168, 85, 247, 0.45);
    color: #d8b4fe;
}

.status-badge.status-resolved,
.status-badge.status-closed {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.4);
    color: #86efac;
}

.status-badge.status-critical {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    color: #fca5a5;
}

.status-badge.status-medium {
    background: rgba(234, 179, 8, 0.15);
    border-color: rgba(234, 179, 8, 0.4);
    color: #fde047;
}

.timeline {
    list-style: none;
    margin: 16px 0 0;
    padding: 0;
    text-align: left;
}

.timeline li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.timeline li:last-child {
    border-bottom: none;
}

.timeline-date {
    color: var(--text-dim);
    font-size: 0.78rem;
    margin-bottom: 2px;
}

@media (max-width: 480px) {
    .severity-group {
        flex-direction: column;
    }
    .location-row {
        flex-direction: column;
    }
    .tracking-code {
        font-size: 1.8rem;
        letter-spacing: 5px;
    }
}

/* ---------- Safety Center (case list / detail) ---------- */

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin: 16px 0;
}

.filter-bar select {
    width: auto;
}

.badge-overdue {
    display: inline-block;
    background: rgba(239, 68, 68, 0.18);
    border: 1px solid rgba(239, 68, 68, 0.5);
    color: #fca5a5;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    animation: pulse-overdue 1.6s infinite;
}

@keyframes pulse-overdue {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

.detail-grid {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 20px;
    margin-top: 16px;
}

.detail-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.detail-card h2 {
    margin-top: 0;
    font-size: 1.05rem;
}

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

/* ---------- Simple dependency-free bar chart (Dashboard) ---------- */

.bar-chart-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.bar-chart-label {
    width: 160px;
    flex-shrink: 0;
    color: var(--text-dim);
}

.bar-chart-track {
    flex: 1;
    background: var(--input-bg);
    border-radius: 6px;
    overflow: hidden;
    height: 18px;
}

.bar-chart-fill {
    height: 100%;
    background: var(--accent);
}

.bar-chart-value {
    width: 40px;
    text-align: right;
    flex-shrink: 0;
}

.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin: 20px 0;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
}

.stat-card .stat-value {
    font-size: 1.7rem;
    font-weight: 700;
}

.stat-card .stat-label {
    color: var(--text-dim);
    font-size: 0.82rem;
    margin-top: 4px;
}

.stat-card.stat-danger .stat-value {
    color: #fca5a5;
}
