:root {
  color-scheme: light;
  --ink: #18332f;
  --muted: #69807b;
  --line: #dce5e1;
  --soft: #f2f6f4;
  --paper: #ffffff;
  --brand: #173c36;
  --brand-2: #245f54;
  --accent: #e59545;
  --danger: #c45148;
  --success: #318368;
  --warning: #cc8a34;
  --shadow: 0 18px 50px rgba(26, 59, 52, .09);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; background: #edf3f0; color: var(--ink); }
body { overflow-x: hidden; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(229, 149, 69, .35); outline-offset: 2px; }
a { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: .45rem; font-size: clamp(1.6rem, 3vw, 2.25rem); letter-spacing: -.035em; }
h2 { font-size: 1.18rem; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin-bottom: .55rem; color: var(--accent); font-size: .76rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.mono { font-family: "SFMono-Regular", Consolas, monospace; }

.login { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 1fr) minmax(360px, 520px); background: var(--brand); }
.login__story { position: relative; display: flex; flex-direction: column; justify-content: space-between; min-height: 100vh; padding: clamp(2rem, 6vw, 6rem); overflow: hidden; color: #f8f2e3; }
.login__story::before, .login__story::after { content: ""; position: absolute; border: 1px solid rgba(255,255,255,.1); border-radius: 50%; }
.login__story::before { width: 38rem; height: 38rem; top: -17rem; right: -10rem; }
.login__story::after { width: 24rem; height: 24rem; bottom: -11rem; left: -8rem; }
.brand { position: relative; z-index: 1; display: flex; align-items: center; gap: .9rem; font-size: 1.15rem; font-weight: 800; letter-spacing: -.02em; }
.brand__mark { width: 2.7rem; height: 2.7rem; display: grid; place-items: center; border-radius: .8rem; background: var(--accent); color: var(--brand); font-weight: 900; }
.login__headline { position: relative; z-index: 1; max-width: 690px; margin: 3rem 0; font-size: clamp(2.2rem, 5.3vw, 5rem); line-height: .98; letter-spacing: -.065em; }
.login__features { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: .75rem; }
.login__features span { padding: .65rem .85rem; border: 1px solid rgba(255,255,255,.15); border-radius: 999px; background: rgba(255,255,255,.06); font-size: .88rem; }
.login__panel { min-height: 100vh; display: grid; place-items: center; padding: 2rem; background: #f6f7f3; }
.login__card { width: min(100%, 390px); }
.login__card h1 { font-size: 2rem; }
.credentials { margin: 1rem 0 1.25rem; padding: .9rem; border: 1px solid #d9e4df; border-radius: .85rem; background: #fff; font-size: .83rem; line-height: 1.55; }

.field { display: grid; gap: .4rem; margin-bottom: .9rem; }
.field > span, .field > label { font-size: .83rem; font-weight: 750; }
.field small { color: var(--muted); }
input, select, textarea { width: 100%; min-height: 44px; padding: .72rem .8rem; border: 1px solid #cad8d3; border-radius: .7rem; background: #fff; color: var(--ink); }
textarea { min-height: 90px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 1.1rem; min-height: 1.1rem; accent-color: var(--brand-2); }
.check { display: flex; align-items: center; gap: .55rem; min-height: 40px; font-size: .9rem; }
.check input { flex: 0 0 auto; }
.error { min-height: 1.25rem; color: var(--danger); font-size: .85rem; }

.btn { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .68rem 1rem; border: 0; border-radius: .7rem; background: var(--brand); color: #fff; font-weight: 750; cursor: pointer; text-decoration: none; transition: transform .15s ease, background .15s ease; }
.btn:hover { background: var(--brand-2); transform: translateY(-1px); }
.btn:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.btn--wide { width: 100%; }
.btn--soft { background: #e5eeea; color: var(--brand); }
.btn--soft:hover { background: #d4e3dd; }
.btn--accent { background: var(--accent); color: #2e2318; }
.btn--accent:hover { background: #edaa67; }
.btn--danger { background: #f9e9e7; color: var(--danger); }
.btn--icon { min-width: 42px; padding-inline: .7rem; }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 254px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 1.35rem 1rem; overflow: auto; background: var(--brand); color: #d9e8e3; }
.sidebar .brand { padding: .2rem .5rem 1.4rem; color: #fff; }
.sidebar .brand__mark { width: 2.25rem; height: 2.25rem; border-radius: .65rem; }
.nav-section { margin: 1rem .55rem .35rem; color: #7fa197; font-size: .68rem; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }
.nav-link { width: 100%; min-height: 42px; display: flex; align-items: center; gap: .75rem; margin: .18rem 0; padding: .65rem .75rem; border: 0; border-radius: .7rem; background: transparent; color: inherit; cursor: pointer; text-align: left; }
.nav-link:hover, .nav-link.active { background: rgba(255,255,255,.1); color: #fff; }
.nav-link__icon { width: 1.4rem; font-size: 1.05rem; text-align: center; }
.sidebar__bottom { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,.1); }
.workspace { min-width: 0; }
.topbar { position: sticky; z-index: 20; top: 0; min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem clamp(1rem, 3vw, 2.4rem); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.88); backdrop-filter: blur(14px); }
.topbar__title { font-weight: 800; }
.topbar__right { display: flex; align-items: center; gap: .7rem; }
.avatar { width: 2.55rem; height: 2.55rem; display: grid; place-items: center; border-radius: 50%; background: #dfeae6; color: var(--brand); font-weight: 850; }
.mobile-menu { display: none; }
.main { width: min(1480px, 100%); margin: 0 auto; padding: clamp(1.1rem, 3vw, 2.4rem); }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-head p { max-width: 680px; margin-bottom: 0; color: var(--muted); }

.grid { display: grid; gap: 1rem; }
.grid--metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric, .card { border: 1px solid var(--line); border-radius: 1rem; background: var(--paper); box-shadow: var(--shadow); }
.metric { position: relative; min-height: 135px; padding: 1.15rem; overflow: hidden; }
.metric::after { content: ""; position: absolute; right: -2rem; bottom: -2rem; width: 6rem; height: 6rem; border-radius: 50%; background: var(--soft); }
.metric__label { color: var(--muted); font-size: .82rem; font-weight: 700; }
.metric__value { margin-top: .55rem; font-size: 2rem; font-weight: 850; letter-spacing: -.045em; }
.metric__hint { margin-top: .25rem; color: var(--success); font-size: .78rem; }
.card { padding: 1.15rem; }
.card--flush { padding: 0; overflow: hidden; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.card__head h2 { margin: 0; }
.stack { display: grid; gap: .75rem; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .8rem; border: 1px solid var(--line); border-radius: .75rem; background: #fff; }
.list-row__main { min-width: 0; }
.list-row__title { font-weight: 750; }
.list-row__meta { margin-top: .2rem; color: var(--muted); font-size: .8rem; }
.score { min-width: 3.25rem; padding: .4rem .55rem; border-radius: .6rem; background: #e3f2eb; color: var(--success); font-weight: 850; text-align: center; }
.score.bad { background: #f9e7e5; color: var(--danger); }
.empty { padding: 2.5rem 1rem; color: var(--muted); text-align: center; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; margin-bottom: 1rem; }
.toolbar .search { min-width: min(330px, 100%); flex: 1; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 1rem; background: #fff; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: .85rem .9rem; border-bottom: 1px solid #e7eeeb; text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; background: #f4f7f5; color: #536e67; font-size: .73rem; letter-spacing: .03em; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
.row-actions { display: flex; gap: .4rem; justify-content: flex-end; }
.icon-action { min-width: 36px; min-height: 36px; display: inline-grid; place-items: center; border: 0; border-radius: .6rem; background: var(--soft); color: var(--brand); cursor: pointer; }
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .32rem .55rem; border-radius: 999px; background: #e7f2ed; color: var(--success); font-size: .75rem; font-weight: 800; }
.badge--gray { background: #edf1ef; color: #687d77; }
.badge--warn { background: #fbefdd; color: #9a641f; }
.badge--danger { background: #fae8e6; color: var(--danger); }

.modal-backdrop { position: fixed; z-index: 60; inset: 0; display: grid; place-items: center; padding: 1rem; background: rgba(15, 40, 35, .55); backdrop-filter: blur(4px); }
.modal { width: min(720px, 100%); max-height: min(850px, 92vh); overflow: auto; padding: 1.25rem; border-radius: 1rem; background: #fff; box-shadow: 0 30px 80px rgba(8,28,24,.25); }
.modal--large { width: min(980px, 100%); }
.modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.modal__head h2 { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem 1rem; }
.form-grid .field { margin: 0; }
.span-2 { grid-column: 1 / -1; }
.divider { height: 1px; margin: 1rem 0; background: var(--line); }

.template-card { display: flex; flex-direction: column; min-height: 230px; padding: 1.1rem; border: 1px solid var(--line); border-radius: 1rem; background: #fff; box-shadow: var(--shadow); }
.template-card__tag { align-self: flex-start; margin-bottom: 1rem; }
.template-card h2 { margin-bottom: .45rem; }
.template-card p { flex: 1; color: var(--muted); font-size: .86rem; line-height: 1.5; }
.template-card__stats { display: flex; gap: 1rem; margin: .8rem 0; font-size: .78rem; color: var(--muted); }
.template-editor__block { margin-bottom: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: .9rem; background: #f8faf9; }
.template-editor__item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .7rem; margin-top: .65rem; padding: .75rem; border-radius: .7rem; background: #fff; }
.template-editor__options { display: flex; flex-wrap: wrap; gap: .75rem; grid-column: 1 / -1; }

.inspection-picker { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 1rem; }
.mobile-preview { max-width: 460px; min-height: 680px; margin: 0 auto; overflow: hidden; border: 10px solid #17332e; border-radius: 2rem; background: #f6f8f6; box-shadow: 0 24px 70px rgba(20,52,45,.2); }
.mobile-preview__head { padding: 1.2rem 1rem 1rem; background: var(--brand); color: #fff; }
.mobile-preview__head h2 { margin: .35rem 0 0; font-size: 1.25rem; }
.progress { height: .45rem; overflow: hidden; border-radius: 999px; background: #dfe9e5; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .2s; }
.mobile-preview__body { padding: 1rem; }
.question { padding: 1rem; border: 1px solid var(--line); border-radius: .9rem; background: #fff; }
.question__count { color: var(--muted); font-size: .74rem; font-weight: 800; }
.question h3 { margin: .5rem 0 1rem; font-size: 1.08rem; line-height: 1.4; }
.answer-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.answer { min-height: 52px; border: 1px solid var(--line); border-radius: .75rem; background: #fff; color: var(--ink); font-weight: 800; cursor: pointer; }
.answer.active[data-value="yes"] { border-color: var(--success); background: #e4f3ec; color: var(--success); }
.answer.active[data-value="no"] { border-color: var(--danger); background: #fae9e7; color: var(--danger); }
.answer.active[data-value="skip"] { background: #edf1ef; color: var(--muted); }
.photo-control { display: block; margin-top: .75rem; padding: .75rem; border: 1px dashed #b8ccc5; border-radius: .7rem; color: var(--brand-2); font-size: .82rem; font-weight: 750; text-align: center; cursor: pointer; }
.photo-control input { display: none; }
.photo-preview { width: 100%; max-height: 180px; margin-top: .75rem; object-fit: cover; border-radius: .7rem; }
.inspection-nav { display: flex; justify-content: space-between; gap: .6rem; margin-top: 1rem; }

.kanban { display: grid; grid-template-columns: repeat(3, minmax(260px, 1fr)); gap: 1rem; overflow-x: auto; }
.kanban__column { min-height: 360px; padding: .8rem; border-radius: 1rem; background: #e8efec; }
.kanban__head { display: flex; justify-content: space-between; padding: .4rem .3rem .8rem; font-size: .82rem; font-weight: 850; }
.task-card { margin-bottom: .65rem; padding: .85rem; border: 1px solid var(--line); border-radius: .8rem; background: #fff; box-shadow: 0 6px 18px rgba(20,52,45,.06); }
.task-card__title { font-weight: 780; }
.task-card__meta { margin: .5rem 0; color: var(--muted); font-size: .76rem; line-height: 1.5; }

.bar-chart { display: grid; gap: .75rem; }
.bar { display: grid; grid-template-columns: minmax(110px, 1fr) 3fr 45px; align-items: center; gap: .75rem; font-size: .82rem; }
.bar__track { height: .65rem; overflow: hidden; border-radius: 999px; background: #e6eeeb; }
.bar__fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand-2), #70a890); }

.toast { position: fixed; z-index: 100; right: 1.2rem; bottom: 1.2rem; max-width: min(390px, calc(100vw - 2rem)); padding: .9rem 1rem; border-radius: .8rem; background: #173c36; color: #fff; box-shadow: 0 16px 50px rgba(14,42,36,.25); }
.toast.error { background: #8f3e39; }

@media (max-width: 1100px) {
  .grid--metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inspection-picker { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .login { grid-template-columns: 1fr; }
  .login__story { min-height: 38vh; padding: 1.5rem; }
  .login__headline { margin: 2.2rem 0; font-size: clamp(2.3rem, 11vw, 4rem); }
  .login__panel { min-height: 62vh; padding: 1.5rem; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; inset: 0 auto 0 0; width: min(85vw, 300px); transform: translateX(-105%); transition: transform .2s ease; box-shadow: 15px 0 50px rgba(5,24,20,.2); }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu { display: inline-flex; }
  .topbar { min-height: 62px; }
  .topbar__user { display: none; }
  .page-head { align-items: stretch; flex-direction: column; }
  .grid--3, .grid--2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .modal { max-height: 94vh; padding: 1rem; }
  .mobile-preview { min-height: 650px; border-width: 0; border-radius: 1rem; }
}

@media (max-width: 560px) {
  .main { padding: 1rem .75rem 5rem; }
  .grid--metrics { grid-template-columns: 1fr 1fr; gap: .65rem; }
  .metric { min-height: 120px; padding: .9rem; }
  .metric__value { font-size: 1.6rem; }
  .template-card { min-height: 0; }
  .bar { grid-template-columns: 90px 1fr 38px; }
  .answer-grid { grid-template-columns: 1fr; }
  .inspection-nav .btn { flex: 1; }
  th, td { padding: .75rem; }
}

