:root {
    --ink: #18211d;
    --muted: #65716b;
    --line: #dfe6e1;
    --surface: #ffffff;
    --canvas: #f4f7f4;
    --green: #1d6b4f;
    --green-dark: #12523c;
    --green-soft: #e4f2eb;
    --amber: #9b6219;
    --danger: #a63a3a;
    --shadow: 0 14px 40px rgba(25, 47, 37, .08);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--canvas);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: var(--canvas); color: var(--ink); }
a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-dark); }
button, input, textarea, select { font: inherit; }
code { padding: .14rem .36rem; border-radius: .35rem; background: #edf2ef; font-size: .88em; }

.app-header {
    position: sticky; top: 0; z-index: 20;
    display: grid; grid-template-columns: 1fr auto; align-items: center;
    gap: 2rem; min-height: 72px; padding: 0 4vw;
    border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96);
    backdrop-filter: blur(14px);
}
.brand { display: inline-flex; align-items: center; gap: .75rem; color: var(--ink); }
.brand strong, .brand small { display: block; }
.brand small { margin-top: .15rem; color: var(--muted); font-size: .72rem; }
.brand-mark { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; background: var(--green); color: white; font-size: 1.4rem; font-weight: 800; box-shadow: 0 8px 22px rgba(29,107,79,.24); }
.brand-mark.small { width: 38px; height: 38px; border-radius: 12px; font-size: 1rem; }
.app-header nav { display: flex; gap: 1.4rem; font-size: .92rem; }
.app-header nav a { color: var(--ink); font-weight: 650; }
.nav-muted { color: #a1aaa5; }
.user-menu { justify-self: end; display: flex; align-items: center; gap: .8rem; font-size: .86rem; }
.user-menu form { margin: 0; }

.page-shell { width: min(1480px, 92vw); margin: 0 auto; padding: 2.2rem 0 5rem; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 2rem; margin-bottom: 1.6rem; }
.page-heading h1 { margin: .2rem 0 .35rem; font-size: clamp(2rem, 4vw, 3.1rem); letter-spacing: -.045em; }
.destination-heading { align-items: center; }
.heading-actions { display: flex; align-items: center; gap: .65rem; flex-wrap: wrap; }
.eyebrow { margin: 0; color: var(--green); font-size: .72rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.muted { margin: 0; color: var(--muted); line-height: 1.55; }
.back-link { display: inline-block; margin-bottom: 1.1rem; font-weight: 650; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: .65rem 1rem; border: 1px solid var(--line); border-radius: .72rem; background: white; color: var(--ink); font-weight: 700; cursor: pointer; }
.button:hover { border-color: #bfcac3; color: var(--ink); }
.button:disabled { cursor: not-allowed; opacity: .48; }
.button-primary { border-color: var(--green); background: var(--green); color: white; }
.button-primary:hover { background: var(--green-dark); color: white; }
.button-quiet { min-height: 34px; padding: .35rem .65rem; background: transparent; }
.button-small { min-height: 34px; padding: .4rem .7rem; font-size: .82rem; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.metric-grid article { padding: 1.1rem 1.2rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); box-shadow: 0 7px 24px rgba(26,49,39,.04); }
.metric-grid span { display: block; color: var(--muted); font-size: .8rem; }
.metric-grid strong { display: block; margin-top: .35rem; font-size: 1.8rem; letter-spacing: -.04em; }
.metric-grid.compact strong { font-size: 1.45rem; }

.panel { border: 1px solid var(--line); border-radius: 1.1rem; background: var(--surface); box-shadow: var(--shadow); }
.panel-toolbar, .panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 1.2rem; padding: 1.25rem 1.35rem; border-bottom: 1px solid var(--line); }
.panel-toolbar h2, .panel-heading h2 { margin: 0 0 .25rem; font-size: 1.1rem; }
.panel-toolbar input { width: min(360px, 42vw); }
.save-state { padding: .32rem .58rem; border-radius: 999px; background: #f0f3f1; color: var(--muted); font-size: .74rem; font-weight: 750; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: .78rem 1rem; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .7rem; letter-spacing: .08em; text-align: left; text-transform: uppercase; }
td { padding: .9rem 1rem; border-bottom: 1px solid #edf1ee; vertical-align: middle; font-size: .88rem; }
tbody tr:hover { background: #fafcfb; }
td strong, td small { display: block; }
td small { margin-top: .22rem; color: var(--muted); }
.status-dot { display: inline-block; width: 8px; height: 8px; margin-right: .4rem; border-radius: 50%; background: #c8cfcb; }
.status-dot.is-live { background: #27a36f; box-shadow: 0 0 0 3px #def4e9; }
.pill { display: inline-flex; padding: .34rem .58rem; border-radius: 999px; background: #edf2ef; color: #425049; font-size: .72rem; font-weight: 750; text-transform: capitalize; }
.pill-accent { background: var(--green-soft); color: var(--green-dark); }
.score { width: 88px; height: 6px; overflow: hidden; border-radius: 99px; background: #e7ece9; }
.score span { display: block; height: 100%; border-radius: inherit; background: var(--green); }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.2rem; align-items: start; }
.workspace-main { min-width: 0; }
.workspace-aside { min-width: 0; }
.sticky-panel { position: sticky; top: 92px; padding: 1.25rem; }
.sticky-panel h2 { margin: .35rem 0 1rem; }
.sticky-panel h3 { margin: 1rem 0 .55rem; font-size: .92rem; }
.sticky-panel hr { margin: 1.2rem 0; border: 0; border-top: 1px solid var(--line); }
.readiness-ring { display: flex; align-items: baseline; gap: .55rem; padding: 1rem; border-radius: .9rem; background: var(--green-soft); color: var(--green-dark); }
.readiness-ring strong { font-size: 2rem; }
.readiness-ring span { font-size: .78rem; line-height: 1.25; }
.gap-list { display: grid; gap: .35rem; margin: 0; padding-left: 1.1rem; font-size: .82rem; }
.fact-list { margin: 0; }
.fact-list div { display: flex; justify-content: space-between; gap: .8rem; padding: .45rem 0; border-bottom: 1px solid #edf1ee; font-size: .8rem; }
.fact-list dt { color: var(--muted); }
.fact-list dd { margin: 0; text-align: right; font-weight: 650; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; padding: 1.35rem; }
.form-grid .full { grid-column: 1 / -1; }
label { display: grid; gap: .42rem; color: #33413a; font-size: .78rem; font-weight: 750; }
label span { color: var(--muted); font-weight: 500; }
input, textarea, select { width: 100%; border: 1px solid #ccd6d0; border-radius: .72rem; background: #fff; color: var(--ink); outline: none; }
input, select { min-height: 43px; padding: .65rem .75rem; }
textarea { padding: .75rem; line-height: 1.55; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(29,107,79,.1); }
.form-actions { display: flex; justify-content: flex-end; }
.form-row { display: flex; align-items: end; justify-content: space-between; gap: 1rem; }
.form-row label { width: min(240px, 60%); }

.section-stack { display: grid; gap: .8rem; margin-top: 1rem; }
.content-section { overflow: hidden; }
.content-section summary { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.2rem; cursor: pointer; list-style: none; }
.content-section summary::-webkit-details-marker { display: none; }
.content-section summary small, .content-section summary strong { display: block; }
.content-section summary small { margin-bottom: .2rem; color: var(--muted); font-size: .65rem; letter-spacing: .08em; text-transform: uppercase; }
.content-section form { display: grid; gap: .9rem; padding: 0 1.2rem 1.2rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.section-status { padding: .28rem .5rem; border-radius: 999px; background: #f1f3f2; color: var(--muted); font-size: .68rem; font-weight: 750; }
.section-status.complete { background: var(--green-soft); color: var(--green-dark); }

.notice { padding: .8rem 1rem; border-radius: .75rem; font-size: .85rem; line-height: 1.45; }
.notice-error { background: #fbe8e8; color: #7f2727; }
.notice-success { background: var(--green-soft); color: var(--green-dark); }
.app-notice { width: min(1480px, 92vw); margin: 1rem auto -1rem; }

.auth-shell { display: grid; place-items: center; min-height: 100vh; padding: 2rem; background: radial-gradient(circle at 20% 20%, #dceee4 0, transparent 36%), radial-gradient(circle at 80% 80%, #e8eadc 0, transparent 32%), var(--canvas); }
.auth-card { width: min(440px, 100%); padding: 2rem; border: 1px solid var(--line); border-radius: 1.35rem; background: white; box-shadow: 0 26px 80px rgba(28,58,44,.13); }
.auth-card .brand-mark { margin-bottom: 1rem; }
.auth-card h1 { margin: .25rem 0 .45rem; font-size: 2rem; letter-spacing: -.04em; }
.auth-card form { display: grid; gap: 1rem; margin-top: 1.4rem; }

.image-library { margin-top: 1rem; overflow: hidden; }
.image-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; padding: 1.25rem; border-bottom: 1px solid var(--line); }
.image-card { overflow: hidden; border: 1px solid var(--line); border-radius: .9rem; background: #fafcfb; }
.image-preview { display: grid; place-items: center; aspect-ratio: 16 / 10; overflow: hidden; background: #e7ede9; color: var(--muted); font-size: .78rem; text-align: center; }
.image-preview img { width: 100%; height: 100%; object-fit: cover; }
.image-card-body { display: grid; gap: .55rem; padding: .85rem; }
.image-card-body small { color: var(--muted); line-height: 1.4; }
.image-card-meta { display: flex; gap: .35rem; flex-wrap: wrap; }
.source-link { font-size: .76rem; font-weight: 750; }
.empty-state { margin: 1.25rem; padding: 1.2rem; border: 1px dashed #bdc9c2; border-radius: .85rem; background: #fafcfb; color: var(--muted); text-align: center; }
.image-form { border-top: 1px solid var(--line); }
.check-label { display: flex; grid-template-columns: auto 1fr; align-items: center; justify-content: start; }
.check-label input { width: 18px; min-height: 18px; }

.worklog-panel { margin-bottom: 1rem; overflow: hidden; }
.worklog-list { display: grid; gap: .8rem; padding: 1.2rem; }
.worklog-entry { padding: 1rem; border: 1px solid var(--line); border-left: 4px solid #aeb8b2; border-radius: .85rem; background: #fcfdfc; }
.worklog-entry.status-in_progress { border-left-color: var(--green); }
.worklog-entry.status-blocked { border-left-color: var(--danger); }
.worklog-entry.status-completed, .worklog-entry.status-info { opacity: .76; }
.worklog-entry-head, .worklog-entry-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.worklog-entry-head time { color: var(--muted); font-size: .72rem; white-space: nowrap; }
.worklog-entry h3 { margin: .75rem 0 .25rem; font-size: 1rem; }
.worklog-tags { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.priority { padding: .24rem .45rem; border-radius: 999px; color: var(--muted); font-size: .68rem; font-weight: 800; text-transform: capitalize; }
.priority-high, .priority-urgent { background: #fff0dc; color: #8a5212; }
.priority-urgent { background: #fbe8e8; color: #8c2929; }
.worklog-destination { display: inline-block; margin-bottom: .55rem; font-size: .78rem; font-weight: 750; }
.worklog-body { color: #3d4a44; font-size: .86rem; line-height: 1.58; }
.next-action { display: grid; gap: .25rem; margin-top: .75rem; padding: .75rem; border-radius: .7rem; background: var(--green-soft); color: var(--green-dark); font-size: .82rem; line-height: 1.5; }
.worklog-entry-foot { margin-top: .8rem; padding-top: .7rem; border-top: 1px solid #e8edea; }
.worklog-entry-foot small { color: var(--muted); }
.worklog-entry-foot form { margin: 0; }
.worklog-add { border-top: 1px solid var(--line); }
.worklog-add summary { padding: 1rem 1.3rem; color: var(--green); cursor: pointer; font-size: .86rem; font-weight: 800; }

.dashboard-contact-panel { margin-bottom: 1rem; }
.contact-ranking-list { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .65rem; margin: 0; padding: 1.1rem 1.2rem 1.25rem; list-style: none; }
.contact-ranking-list li { display: flex; min-width: 0; align-items: flex-start; justify-content: space-between; gap: .8rem; padding: .85rem; border: 1px solid var(--line); border-radius: .85rem; background: #fcfdfc; }
.contact-ranking-list li > span { min-width: 0; }
.contact-ranking-list strong, .contact-ranking-list small { display: block; }
.contact-ranking-list strong { overflow: hidden; font-size: .84rem; text-overflow: ellipsis; white-space: nowrap; }
.contact-ranking-list small { margin-top: .25rem; color: var(--muted); font-size: .68rem; line-height: 1.4; }
.contact-ranking-list b { color: var(--green); font-size: 1.25rem; line-height: 1; text-align: right; }
.contact-ranking-list b small { margin-top: .2rem; font-size: .62rem; font-weight: 750; }
.contact-dashboard-empty, .contact-empty { padding: 1.25rem; color: var(--muted); font-size: .86rem; }
.contacts-shell { max-width: 1180px; }
.contact-periods { display: flex; gap: .45rem; margin: 0 0 1rem; overflow-x: auto; }
.contact-periods a { padding: .55rem .8rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--surface); font-size: .76rem; font-weight: 800; text-decoration: none; white-space: nowrap; }
.contact-periods a.is-active { border-color: var(--green); color: #fff; background: var(--green); }
.contact-ranking-panel { overflow: hidden; }
.contact-table-wrap { border-top: 1px solid var(--line); }
.contact-table { min-width: 760px; }
.contact-stay-cell { display: grid; grid-template-columns: 28px minmax(0, 1fr); align-items: center; gap: .12rem .55rem; }
.contact-stay-cell > span { grid-row: 1 / 3; display: grid; width: 28px; height: 28px; place-items: center; border-radius: 999px; color: var(--green); background: #eaf5ef; font-size: .72rem; font-weight: 850; }
.contact-stay-cell strong, .contact-stay-cell small { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-stay-cell small { color: var(--muted); font-size: .7rem; }

@media (max-width: 980px) {
    .app-header { grid-template-columns: 1fr auto; padding: 0 3vw; }
    .app-header nav { display: none; }
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .workspace-grid { grid-template-columns: 1fr; }
    .sticky-panel { position: static; }
    .image-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .contact-ranking-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    .page-shell { width: min(94vw, 100%); padding-top: 1.4rem; }
    .app-header { min-height: 64px; }
    .brand small, .user-menu > span { display: none; }
    .page-heading { display: grid; align-items: start; }
    .metric-grid { grid-template-columns: 1fr 1fr; }
    .metric-grid article { padding: .9rem; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .full { grid-column: auto; }
    .panel-toolbar { align-items: stretch; flex-direction: column; }
    .panel-toolbar input { width: 100%; }
    .image-grid { grid-template-columns: 1fr; }
    .worklog-entry-head, .worklog-entry-foot { align-items: flex-start; flex-direction: column; }
    .contact-ranking-list { grid-template-columns: 1fr; padding: .9rem; }
    .dashboard-contact-panel .dashboard-card-heading { align-items: flex-start; }
}
