:root {
    --brand: #166534;
    --brand-ink: #0b3d24;
    --brand-soft: #ecf8f0;
    --accent: #b45309;
    --ink: #111827;
    --muted: #6b7280;
    --line: #e5e7eb;
    --bg: #f8faf9;
    --surface: #ffffff;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --ok: #059669;
    --ok-soft: #ecfdf5;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(17, 24, 39, 0.04), 0 4px 16px rgba(17, 24, 39, 0.04);
    --font: "Plus Jakarta Sans", system-ui, sans-serif;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --topbar-h: 58px;
    --bottom-nav-h: 64px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    color: var(--ink);
    background: var(--bg);
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.45;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; }

.container {
    width: min(920px, calc(100% - 1.5rem));
    margin-inline: auto;
}

/* Topbar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--topbar-h);
    background: rgba(255,255,255,0.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}
.topbar-inner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: var(--topbar-h);
    position: relative;
}
.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: inherit;
    text-decoration: none;
    min-width: 0;
}
.brand:hover { text-decoration: none; }
.brand-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    object-fit: cover;
    flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-text strong {
    font-size: 0.98rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.brand-text small {
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 500;
}

.nav-toggle {
    margin-left: auto;
    width: 40px;
    height: 40px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    display: none;
    place-items: center;
    gap: 4px;
    flex-direction: column;
    padding: 0;
}
.nav-toggle span {
    display: block;
    width: 15px;
    height: 1.5px;
    background: var(--ink);
    border-radius: 2px;
}

.nav {
    display: flex;
    gap: 0.2rem;
    margin-left: auto;
    align-items: center;
}
.nav a {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.7rem;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.86rem;
}
.nav a i { font-size: 0.86rem; width: 1em; text-align: center; }
.nav a:hover { background: #f3f4f6; color: var(--ink); text-decoration: none; }
.nav a.active {
    background: var(--brand-soft);
    color: var(--brand-ink);
}
.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: 0.25rem;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    background: #f3f4f6;
    color: var(--ink);
    font-size: 0.78rem;
    font-weight: 600;
}
.user-chip i { color: var(--brand); font-size: 0.8rem; }
.mobile-only { display: none !important; }
.desktop-only { display: inline-flex !important; }

/* Bottom nav (mobile) */
.bottom-nav {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    height: calc(var(--bottom-nav-h) + var(--safe-bottom));
    padding: 0.35rem 0.5rem var(--safe-bottom);
    background: rgba(255,255,255,0.96);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(12px);
    grid-template-columns: repeat(4, 1fr);
    gap: 0.15rem;
}
.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    border-radius: 10px;
    color: var(--muted);
    text-decoration: none;
    font-size: 0.68rem;
    font-weight: 600;
    min-height: 52px;
}
.bottom-nav a i { font-size: 1.1rem; }
.bottom-nav a.active {
    color: var(--brand);
    background: var(--brand-soft);
}
.bottom-nav a:hover { text-decoration: none; }

.main {
    padding: 1.15rem 0 calc(2rem + var(--safe-bottom));
}
.has-bottom-nav .main {
    padding-bottom: calc(var(--bottom-nav-h) + 1.5rem + var(--safe-bottom));
}

.page-head {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: flex-start;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.page-head h1 {
    margin: 0;
    font-size: clamp(1.25rem, 3.5vw, 1.55rem);
    font-weight: 750;
    letter-spacing: -0.03em;
}
.page-head p {
    margin: 0.25rem 0 0;
    color: var(--muted);
    font-size: 0.88rem;
}
.page-actions {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
    align-items: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border: 0;
    border-radius: 10px;
    padding: 0.7rem 1rem;
    font-weight: 650;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    min-height: 42px;
    transition: background 0.15s ease, transform 0.1s ease;
}
.btn i { font-size: 0.9rem; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); text-decoration: none; }
.btn-secondary {
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
}
.btn-secondary:hover { background: #f9fafb; text-decoration: none; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.alert {
    padding: 0.75rem 0.9rem;
    border-radius: 10px;
    margin-bottom: 0.85rem;
    font-weight: 550;
    font-size: 0.9rem;
}
.alert-success { background: var(--ok-soft); color: #047857; }
.alert-error { background: var(--danger-soft); color: var(--danger); }

.search-bar {
    display: flex;
    gap: 0.45rem;
    margin-bottom: 0.85rem;
    flex-wrap: wrap;
}
.search-bar input { flex: 1; min-width: 160px; }

input[type="text"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="date"],
input[type="search"],
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.72rem 0.85rem;
    background: var(--surface);
    color: var(--ink);
    min-height: 44px;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(22, 101, 52, 0.12);
}

.table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    -webkit-overflow-scrolling: touch;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
}
.data-table th, .data-table td {
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
    font-size: 0.9rem;
}
.data-table th {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    background: #fafafa;
    font-weight: 700;
}
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fcfcfc; }
.data-table .empty { text-align: center; color: var(--muted); padding: 2rem; }
.row-actions { white-space: nowrap; }
.row-actions a {
    margin-right: 0.65rem;
    font-weight: 600;
    font-size: 0.86rem;
}

.pagination {
    display: flex;
    gap: 0.3rem;
    margin-top: 0.85rem;
    flex-wrap: wrap;
}
.pagination a {
    min-width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    text-decoration: none;
    color: var(--ink);
    font-weight: 600;
    font-size: 0.86rem;
}
.pagination a.active {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}

.mobile-cards { display: none; gap: 0.55rem; }
.record-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.85rem 0.9rem;
}
.record-card-main {
    display: grid;
    gap: 0.12rem;
    flex: 1;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}
.record-card-main:hover { text-decoration: none; }
.record-card-main strong {
    font-size: 0.98rem;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.record-card-main span,
.record-card-main small {
    color: var(--muted);
    font-size: 0.8rem;
}
.record-card-actions a {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    padding: 0 0.75rem;
    border-radius: 8px;
    background: var(--brand-soft);
    color: var(--brand-ink);
    font-weight: 700;
    font-size: 0.82rem;
    text-decoration: none;
}
.empty-card {
    text-align: center;
    padding: 1.5rem 1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--muted);
}

/* Wizard / form */
.wizard-shell { display: grid; gap: 0.75rem; }
.wizard-progress {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.75rem 0.85rem;
}
.wizard-bar {
    height: 6px;
    background: #eef2f0;
    border-radius: 999px;
    overflow: hidden;
}
.wizard-bar span {
    display: block;
    height: 100%;
    width: 20%;
    background: var(--brand);
    border-radius: inherit;
    transition: width 0.2s ease;
}
.wizard-meta {
    margin: 0.4rem 0 0;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 500;
}
.wizard-steps {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.35rem;
}
.step-pill {
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 10px;
    min-height: 40px;
    font-weight: 750;
    color: var(--muted);
    cursor: pointer;
    font-size: 0.88rem;
}
.step-pill.active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}
.step-pill.done {
    background: var(--brand-soft);
    border-color: #c7e7d2;
    color: var(--brand-ink);
}

.profile-form .form-section,
.view-card,
.narrow-form,
.login-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.form-section { padding: 1rem; }
.wizard-pane[hidden] { display: none !important; }
.form-section h2, .view-card h2 {
    margin: 0 0 0.85rem;
    font-size: 1.02rem;
    font-weight: 750;
    letter-spacing: -0.02em;
    color: var(--brand-ink);
}
.section-head {
    display: flex;
    justify-content: space-between;
    gap: 0.85rem;
    align-items: flex-start;
    margin-bottom: 0.9rem;
    flex-wrap: wrap;
}
.section-head h2 { margin: 0; }

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}
.grid-2 .full, .detail-grid .full { grid-column: 1 / -1; }
.stack-gap { margin-top: 0.75rem; }
label span, fieldset legend {
    display: block;
    margin-bottom: 0.28rem;
    font-size: 0.8rem;
    font-weight: 650;
    color: #374151;
}
.choice-group {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.7rem 0.75rem;
    margin: 0;
    background: #fafafa;
}
.choice-group legend {
    padding: 0 0.2rem;
    margin-bottom: 0.35rem;
}
.choice {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0.2rem 0.65rem 0.2rem 0;
    font-weight: 500;
    font-size: 0.9rem;
    min-height: 34px;
}
.choice input { width: auto; accent-color: var(--brand); }
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.15rem 0.45rem;
}
.skills-grid legend,
.skills-grid .full { grid-column: 1 / -1; }

.photo-upload { display: grid; gap: 0.35rem; justify-items: center; text-align: center; }
.photo-box {
    width: 104px;
    height: 124px;
    border: 1.5px dashed #cbd5d1;
    border-radius: 12px;
    background: #f6f8f7;
    display: grid;
    place-items: center;
    overflow: hidden;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 650;
    cursor: pointer;
    padding: 0.35rem;
}
.photo-box img { width: 100%; height: 100%; object-fit: cover; }
.photo-upload input[type="file"] { display: none; }
.photo-upload .hint,
.photo-upload small { color: var(--muted); font-size: 0.72rem; }
.upload-progress { width: min(200px, 100%); }
.upload-track {
    height: 6px;
    background: #eef2f0;
    border-radius: 999px;
    overflow: hidden;
}
.upload-track span {
    display: block;
    height: 100%;
    width: 0;
    background: var(--brand);
    transition: width 0.15s linear;
}

.form-actions, .wizard-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    position: sticky;
    bottom: calc(0.5rem + var(--safe-bottom));
    background: rgba(248, 250, 249, 0.94);
    backdrop-filter: blur(8px);
    padding: 0.6rem;
    border-radius: 12px;
    border: 1px solid var(--line);
    margin-top: 0.75rem;
    z-index: 20;
}
.has-bottom-nav .wizard-actions {
    bottom: calc(var(--bottom-nav-h) + 0.4rem + var(--safe-bottom));
}
.wizard-actions .btn { flex: 1; }

.view-layout {
    display: grid;
    grid-template-columns: 148px 1fr;
    gap: 0.85rem;
    align-items: start;
}
.photo-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.6rem;
    position: sticky;
    top: calc(var(--topbar-h) + 0.75rem);
}
.photo-panel img {
    width: 100%;
    aspect-ratio: 3/4;
    object-fit: cover;
    border-radius: 8px;
}
.photo-placeholder {
    aspect-ratio: 3/4;
    display: grid;
    place-items: center;
    background: var(--brand-soft);
    color: var(--muted);
    border-radius: 8px;
    font-weight: 650;
    font-size: 0.82rem;
}
.view-sections { display: grid; gap: 0.75rem; }
.view-card { padding: 0.95rem 1rem; }
.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
    margin: 0;
}
.detail-grid dt {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin-bottom: 0.12rem;
    font-weight: 700;
}
.detail-grid dd { margin: 0; font-weight: 550; font-size: 0.92rem; }

.narrow-form {
    max-width: 400px;
    padding: 1rem;
    display: grid;
    gap: 0.75rem;
}

/* Login */
.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 1.25rem;
    background:
        linear-gradient(180deg, #0f3d26 0%, #166534 55%, #1a7a3e 100%);
}
.login-shell { width: min(340px, 100%); }
.login-card {
    padding: 1.35rem 1.15rem 1.15rem;
    box-shadow: 0 18px 40px rgba(0,0,0,0.18);
}
.login-brand { text-align: center; margin-bottom: 1rem; }
.login-brand img {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    margin-inline: auto;
}
.login-brand h1 {
    margin: 0.55rem 0 0.15rem;
    font-size: 1.3rem;
    font-weight: 750;
    letter-spacing: -0.03em;
    color: var(--ink);
}
.login-brand p {
    margin: 0;
    color: var(--muted);
    font-size: 0.88rem;
}
.login-form { display: grid; gap: 0.7rem; }

.footer {
    border-top: 1px solid var(--line);
    padding: 0.9rem 0 calc(1rem + var(--safe-bottom));
    color: var(--muted);
    font-size: 0.78rem;
}
.has-bottom-nav .footer {
    padding-bottom: calc(var(--bottom-nav-h) + 0.75rem + var(--safe-bottom));
}

@media (max-width: 860px) {
    .container { width: min(100% - 1rem, 920px); }
    .desktop-table { display: none; }
    .mobile-cards { display: grid; }
    .grid-2, .detail-grid, .view-layout { grid-template-columns: 1fr; }
    .photo-panel { position: static; max-width: 140px; }
    .desktop-only { display: none !important; }
    .mobile-only { display: inline-flex !important; }
    .nav-toggle { display: none; }
    .nav { display: none !important; }
    .bottom-nav { display: grid; }
    .page-actions { width: 100%; }
    .page-actions .btn { flex: 1; }
    .skills-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 420px) {
    .skills-grid { grid-template-columns: 1fr; }
    .brand-text small { display: none; }
    .form-section { padding: 0.85rem; }
    .step-pill { min-height: 38px; font-size: 0.82rem; }
}
