:root {
    --blue: #0b74d1;
    --blue-dark: #075aa3;
    --green: #21b66f;
    --green-dark: #14945a;
    --teal: #18b7b0;
    --gold: #d8a326;
    --red: #d94747;
    --orange: #e9a33a;
    --ink: #132033;
    --muted: #64748b;
    --line: #d9e2ec;
    --panel: rgba(255, 255, 255, 0.96);
    --soft: #f4f8fc;
    --shadow: 0 20px 45px rgba(8, 40, 84, 0.18);
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 8px;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
    margin: 0;
    color: var(--ink);
    background: #0f5c99;
    min-height: 100vh;
}

body.auth-page,
body.tracking-page,
body.install-page {
    background:
        radial-gradient(circle at 20% 20%, rgba(74, 202, 255, .32) 0 0.7%, transparent 0.75% 3.5%, rgba(74, 202, 255, .22) 3.55% 3.75%, transparent 3.8% 100%),
        radial-gradient(circle at 58% 44%, rgba(255,255,255,.08), transparent 22%),
        linear-gradient(120deg, rgba(0, 59, 132, .96), rgba(4, 132, 155, .92) 48%, rgba(31, 178, 130, .9));
    overflow-x: hidden;
}

body.auth-page::before,
body.tracking-page::before,
body.install-page::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: .58;
    background:
        repeating-linear-gradient(105deg, transparent 0 18px, rgba(160, 241, 255, .18) 19px, transparent 20px 42px),
        radial-gradient(ellipse at 76% 18%, transparent 0 22%, rgba(255,255,255,.12) 22.2% 22.7%, transparent 23% 100%),
        radial-gradient(ellipse at 28% 42%, transparent 0 23%, rgba(255,255,255,.08) 23.2% 23.8%, transparent 24% 100%);
    mask-image: linear-gradient(to bottom, black 0%, black 70%, transparent 100%);
}

body.auth-page::after,
body.tracking-page::after,
body.install-page::after {
    content: "";
    position: fixed;
    left: -10vw;
    right: -10vw;
    bottom: 9vh;
    height: 42vh;
    pointer-events: none;
    opacity: .64;
    background:
        repeating-radial-gradient(ellipse at 28% 72%, transparent 0 10px, rgba(151, 229, 255, .38) 11px 12px, transparent 13px 22px);
    transform: rotate(-7deg);
}

a { color: inherit; text-decoration: none; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 10px;
    min-height: 42px;
    padding: 10px 16px;
    font-weight: 700;
    cursor: pointer;
    line-height: 1.1;
    transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
    font-family: inherit;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--blue), #095eb5);
    box-shadow: 0 8px 18px rgba(12, 116, 209, .24);
}
.btn-outline {
    color: var(--blue-dark);
    border-color: #bad5ef;
    background: #fff;
}
.btn-ghost {
    color: #31516f;
    background: rgba(255,255,255,.7);
}
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 7px 10px; border-radius: 8px; font-size: .88rem; }

.alert {
    padding: 12px 14px;
    border-radius: 12px;
    margin: 0 0 16px;
    font-weight: 650;
    border: 1px solid transparent;
}
.alert-danger { color: #8d1f1f; background: #fff1f1; border-color: #ffd1d1; }
.alert-success { color: #11623d; background: #effdf5; border-color: #bcebd1; }
.alert-warning { color: #7a4e08; background: #fff8e8; border-color: #f2d99c; }
.alert-primary { color: #064b8f; background: #eef6ff; border-color: #c7e1ff; }

.auth-wrapper,
.install-shell {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px 16px;
}

.login-card,
.install-card {
    width: min(100%, 430px);
    border-radius: 18px;
    background: rgba(255,255,255,.96);
    box-shadow: var(--shadow);
    padding: 30px 34px 28px;
    border: 1px solid rgba(255,255,255,.7);
}
.install-card { width: min(100%, 880px); }

.seal,
.brand-seal {
    width: 72px;
    height: 72px;
    display: grid;
    place-items: center;
    margin: 0 auto 18px;
    border-radius: 22px;
    background: linear-gradient(145deg, #ffffff, #edf7ff);
    border: 1px solid rgba(126, 188, 232, .9);
    box-shadow: 0 14px 30px rgba(8, 78, 132, .16), inset 0 0 0 1px rgba(255,255,255,.85);
    color: #0b66b2;
    font-weight: 950;
    letter-spacing: -.06em;
}
.seal span,
.brand-seal {
    font-size: 1.48rem;
    line-height: 1;
}
.brand-seal {
    width: 36px;
    height: 36px;
    margin: 0;
    border-radius: 12px;
    font-size: .92rem;
    box-shadow: 0 8px 18px rgba(8, 78, 132, .12), inset 0 0 0 1px rgba(255,255,255,.85);
}

.login-card h1,
.install-card h1 {
    margin: 0;
    text-align: center;
    font-size: 1.12rem;
    letter-spacing: -.01em;
}
.login-card .subtitle,
.install-card p {
    margin: 6px 0 22px;
    text-align: center;
    color: #3d4f63;
    font-size: .95rem;
}

label { display: block; font-weight: 700; color: #1f2c3d; }
label span { display: block; margin-bottom: 7px; }
label b { color: var(--red); }
label small { color: var(--muted); font-weight: 500; }
input, select, textarea {
    width: 100%;
    min-height: 44px;
    border: 1px solid #cbd6e2;
    background: #fff;
    color: var(--ink);
    border-radius: 10px;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
}
textarea { min-height: 104px; resize: vertical; }
input:focus, select:focus, textarea:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 4px rgba(37, 121, 210, .13);
}
.login-card label { margin-top: 14px; font-size: .92rem; }
.login-card button { margin-top: 18px; }
.privacy-note {
    text-align: center;
    margin: 20px 0 0;
    color: #66778c;
    font-size: .78rem;
    line-height: 1.55;
}

.topbar,
.admin-topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px clamp(16px, 4vw, 50px);
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(212, 226, 239, .95);
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 850;
}
.topbar-user,
.admin-nav {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #21374e;
    font-weight: 700;
}
.admin-nav-link {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 8px 12px;
    border-radius: 999px;
    color: #35516c;
    border: 1px solid transparent;
}
.admin-nav-link:hover,
.admin-nav-link.active {
    color: var(--blue-dark);
    background: #eef6ff;
    border-color: #cfe5fb;
}
.admin-user-label {
    color: #51657a;
    font-size: .92rem;
}
.avatar {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #eef5fb;
    border: 1px solid #d4e1ed;
}

.tracking-shell,
.admin-shell {
    position: relative;
    z-index: 1;
    width: min(100% - 28px, 1180px);
    margin: 28px auto 24px;
}

.panel,
.admin-panel,
.admin-hero,
.kpi-card {
    background: var(--panel);
    border: 1px solid rgba(255,255,255,.75);
    box-shadow: var(--shadow);
    border-radius: var(--radius-lg);
}
.panel { margin-bottom: 18px; overflow: hidden; }
.panel-title {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 24px;
    border-bottom: 1px solid var(--line);
}
.panel-title h1,
.status-heading h2,
.history-panel h2,
.admin-hero h1,
.section-title-row h2 {
    margin: 0;
    font-size: clamp(1.2rem, 2vw, 1.55rem);
    letter-spacing: -.02em;
}
.profile-icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #eef6ff;
    border: 1px solid #d7e8fa;
}
.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px 44px;
    padding: 24px 30px 28px;
}
.profile-item {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 10px;
    align-items: start;
}
.profile-item span { font-weight: 850; }
.profile-item strong { font-size: 1.08rem; line-height: 1.35; }

.status-panel { padding-bottom: 22px; }
.status-heading {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px 18px;
    border-bottom: 1px solid var(--line);
}
.status-heading p { color: var(--muted); margin: 6px 0 0; }
.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 7px 12px;
    font-weight: 850;
    font-size: .88rem;
    white-space: nowrap;
}
.status-pill.primary { color: #0b58a2; background: #ddecff; }
.status-pill.success { color: #0d7a49; background: #dff8eb; }
.status-pill.warning { color: #80520a; background: #fff1ce; }
.status-pill.danger { color: #9a2424; background: #ffe2e2; }

.timeline {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0;
    padding: 24px 28px 14px;
}
.timeline-item { position: relative; min-width: 0; padding: 0 8px 10px; text-align: center; }
.timeline-top { position: relative; height: 50px; display: flex; justify-content: center; align-items: center; }
.timeline-line {
    position: absolute;
    left: 50%;
    right: -50%;
    top: 50%;
    height: 8px;
    transform: translateY(-50%);
    background: #c7cbd1;
    z-index: 0;
}
.timeline-item:last-child .timeline-line { display: none; }
.timeline-marker {
    position: relative;
    z-index: 1;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #f0f2f5;
    color: #8a929f;
    border: 5px solid #c7cbd1;
    font-weight: 900;
    font-size: 1.1rem;
}
.timeline-item.completed .timeline-marker,
.timeline-item.completed .timeline-line { background: var(--green); color: #fff; border-color: var(--green); }
.timeline-item.current .timeline-marker { background: var(--blue); color: #fff; border-color: #74b6f0; box-shadow: 0 0 0 7px rgba(11,116,209,.18); }
.timeline-item.paused .timeline-marker { background: var(--orange); color: #fff; border-color: #f4cc86; }
.timeline-item.cancelled .timeline-marker { background: var(--red); color: #fff; border-color: #f0a4a4; }
.timeline-item h3 {
    margin: 0 auto 8px;
    font-size: .98rem;
    line-height: 1.2;
    min-height: 44px;
}
.step-badge {
    display: inline-flex;
    border-radius: 999px;
    background: #e6e9ed;
    color: #4b5563;
    padding: 4px 9px;
    font-weight: 800;
    font-size: .78rem;
    margin-bottom: 8px;
}
.timeline-item.completed .step-badge { color: #087143; background: #d8f7e8; }
.timeline-item.current .step-badge { color: #0a559e; background: #ddebff; }
.timeline-item.paused .step-badge { color: #7a4e08; background: #fff0cc; }
.timeline-item.cancelled .step-badge { color: #942626; background: #ffe1e1; }
.timeline-item p { margin: 0; font-weight: 650; line-height: 1.25; font-size: .88rem; }
.current-note {
    margin-top: 9px;
    border: 1px solid #90bce9;
    background: #eef7ff;
    color: #1e3d5f;
    padding: 9px;
    text-align: left;
    border-radius: 8px;
    font-size: .84rem;
    line-height: 1.35;
}
.current-summary {
    margin: 12px 24px 0;
    display: flex;
    justify-content: space-between;
    gap: 18px;
    border-radius: 14px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #eff7ff, #f6fbff);
    border: 1px solid #d5e8fb;
}
.current-summary span { display: block; color: var(--muted); font-weight: 800; margin-bottom: 4px; }
.current-summary strong { font-size: 1.05rem; }
.current-summary p { margin: 0; color: #3f5570; max-width: 520px; }

.history-panel { padding: 20px 24px; }
.history-list { display: grid; gap: 10px; margin-top: 14px; }
.history-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px 16px;
    padding: 12px 14px;
    border: 1px solid #dce7f2;
    border-radius: 12px;
    background: #fbfdff;
}
.history-row span { color: var(--muted); display: block; margin-top: 2px; }
.history-row time { color: var(--muted); font-weight: 700; font-size: .9rem; }
.history-row p { grid-column: 1 / -1; margin: 0; color: #334960; }
.site-footer {
    position: relative;
    z-index: 1;
    text-align: center;
    color: rgba(255,255,255,.92);
    font-size: .86rem;
    padding: 0 16px 26px;
}

body.admin-page {
    background: #f2f6fb;
    min-height: 100vh;
}
.admin-topbar {
    background: rgba(255,255,255,.96);
}
.admin-shell { margin-top: 22px; }
.admin-hero {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    padding: 24px;
    margin-bottom: 18px;
    box-shadow: 0 12px 30px rgba(40, 71, 105, .08);
}
.admin-hero p { max-width: 760px; color: var(--muted); margin: 8px 0 0; }
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 18px;
}
.kpi-card {
    padding: 18px;
    box-shadow: 0 10px 24px rgba(40, 71, 105, .08);
}
.kpi-card span { color: var(--muted); font-weight: 800; }
.kpi-card strong { display: block; font-size: 2rem; margin-top: 6px; }
.kpi-card em { color: var(--muted); font-style: normal; font-weight: 700; }
.admin-panel {
    padding: 20px;
    margin-bottom: 18px;
    box-shadow: 0 12px 30px rgba(40, 71, 105, .08);
}
.section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}
.search-form {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    max-width: 620px;
}
.search-form input { min-width: 240px; }
.form-panel { border-top: 5px solid var(--blue); }
.admin-form .form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}
.admin-form .wide { grid-column: 1 / -1; }
.admin-form textarea { line-height: 1.55; }
.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
}
.check-row input { width: 18px; min-height: 18px; }
.check-row span { margin: 0; }
.form-actions,
.install-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 18px;
}
.table-wrap { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 880px;
}
.data-table th,
.data-table td {
    padding: 13px 12px;
    text-align: left;
    border-bottom: 1px solid #e1e9f1;
    vertical-align: top;
}
.data-table th {
    background: #f6f9fc;
    color: #43566b;
    font-size: .9rem;
    white-space: nowrap;
}
.data-table td strong,
.data-table td small { display: block; }
.data-table td small { color: var(--muted); margin-top: 3px; }
.empty-cell { text-align: center !important; color: var(--muted); padding: 26px !important; }
.action-cell { white-space: nowrap; }
.inactive-label { display: block; margin-top: 6px; color: #9a2424; font-size: .85rem; font-weight: 800; }
.muted-row { opacity: .62; }

.install-note {
    margin-top: 20px;
    padding: 14px;
    background: #fff8df;
    border: 1px solid #f0d78a;
    border-radius: 12px;
    color: #654714;
}
.code-box {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    white-space: pre;
    background: #0f172a;
    color: #e2e8f0;
    border: 0;
    line-height: 1.45;
}

@media (max-width: 1080px) {
    .timeline { grid-template-columns: repeat(3, 1fr); row-gap: 18px; }
    .timeline-item:nth-child(3n) .timeline-line { display: none; }
    .timeline-item:last-child .timeline-line { display: none; }
}

@media (max-width: 760px) {
    .hide-sm { display: none; }
    .login-card { padding: 24px 20px; }
    .tracking-shell,
    .admin-shell { width: min(100% - 18px, 1180px); margin-top: 14px; }
    .topbar,
    .admin-topbar { padding: 9px 12px; }
    .admin-topbar,
    .admin-hero,
    .section-title-row,
    .status-heading,
    .current-summary { flex-direction: column; align-items: stretch; }
    .admin-nav { flex-wrap: wrap; justify-content: flex-end; }
    .profile-grid { grid-template-columns: 1fr; padding: 18px; gap: 12px; }
    .profile-item { grid-template-columns: 1fr; gap: 2px; }
    .panel-title { padding: 16px 18px; }
    .timeline { grid-template-columns: 1fr; padding: 16px 18px; }
    .timeline-item { display: grid; grid-template-columns: 54px 1fr; text-align: left; gap: 0 12px; padding: 0 0 18px; }
    .timeline-top { grid-row: 1 / span 4; height: auto; align-items: start; padding-top: 2px; }
    .timeline-line { left: 50%; right: auto; top: 42px; width: 7px; height: calc(100% + 2px); transform: translateX(-50%); }
    .timeline-item:nth-child(3n) .timeline-line { display: block; }
    .timeline-item:last-child .timeline-line { display: none; }
    .timeline-item h3 { min-height: auto; margin: 0 0 7px; }
    .current-note { grid-column: 2; }
    .current-summary { margin: 8px 18px 0; }
    .history-row { grid-template-columns: 1fr; }
    .kpi-grid,
    .admin-form .form-grid { grid-template-columns: 1fr; }
    .search-form { max-width: none; width: 100%; flex-wrap: wrap; }
    .search-form input { min-width: 100%; }
    .form-actions { justify-content: stretch; flex-direction: column; }
    .form-actions .btn { width: 100%; }
}

@media (max-width: 420px) {
    .brand span:last-child { max-width: 210px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .seal { width: 62px; height: 62px; }
    .timeline-marker { width: 38px; height: 38px; }
}

.install-url, .system-title-th {
    margin-top: 4px;
    color: var(--muted);
    font-weight: 600;
}


.settings-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}
.settings-sidebar h2 {
    margin: 0 0 14px;
    font-size: 1.1rem;
}
.settings-menu {
    display: grid;
    gap: 8px;
}
.settings-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid #dce7f2;
    background: #fbfdff;
    color: #2d4258;
    font-weight: 850;
}
.settings-menu-item small {
    color: var(--muted);
    font-weight: 700;
    white-space: nowrap;
}
.settings-menu-item.active {
    color: var(--blue-dark);
    border-color: #b9daf7;
    background: #eef7ff;
}
.settings-panel .panel-help {
    margin: 6px 0 0;
    color: var(--muted);
    font-weight: 600;
}
.master-form {
    padding: 16px;
    border: 1px solid #dce7f2;
    border-radius: 14px;
    background: #fbfdff;
    margin-bottom: 18px;
}
.master-grid {
    grid-template-columns: 180px minmax(220px, 1fr) 160px 180px !important;
    align-items: end;
}
.master-table-wrap .data-table,
.master-table {
    min-width: 720px;
}
.inline-form {
    display: inline;
    margin: 0;
}
.action-stack {
    display: flex;
    gap: 8px;
    align-items: center;
}

@media (max-width: 900px) {
    .settings-layout { grid-template-columns: 1fr; }
    .settings-menu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .master-grid { grid-template-columns: 1fr !important; }
}

@media (max-width: 760px) {
    .admin-nav { justify-content: flex-start; width: 100%; }
    .admin-user-label { width: 100%; }
    .settings-menu { grid-template-columns: 1fr; }
    .action-stack { flex-direction: column; align-items: stretch; }
    .action-stack .btn { width: 100%; }
}
