/* MyWerkz offline prototype: design tokens + components. System fonts and inline SVG only (works with no internet). */
:root {
  --brand: #0f766e; --brand-ink: #ffffff; --brand-soft: #e0f2f1;
  --bg: #f4f6f7; --surface: #ffffff; --surface-2: #eef2f3; --line: #d9e1e3;
  --ink: #12262a; --mut: #5a6e72;
  --ok: #15803d; --ok-bg: #dcfce7; --warn: #a16207; --warn-bg: #fef3c7; --bad: #b91c1c; --bad-bg: #fee2e2; --info: #1d4ed8; --info-bg: #dbeafe;
  --shadow: 0 1px 2px rgba(15, 40, 45, .06), 0 4px 14px rgba(15, 40, 45, .05);
  --r: 16px; --rc: 10px; --side: 248px; --tab: 64px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --brand: #2dd4bf; --brand-ink: #062a27; --brand-soft: #123c38;
  --bg: #0c1517; --surface: #142124; --surface-2: #1b2c30; --line: #28403f;
  --ink: #e7f1f2; --mut: #9db3b6;
  --ok: #4ade80; --ok-bg: #12331f; --warn: #fbbf24; --warn-bg: #3a2c0a; --bad: #f87171; --bad-bg: #3d1717; --info: #93c5fd; --info-bg: #162a4d;
  --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #2dd4bf; --brand-ink: #062a27; --brand-soft: #123c38;
    --bg: #0c1517; --surface: #142124; --surface-2: #1b2c30; --line: #28403f;
    --ink: #e7f1f2; --mut: #9db3b6;
    --ok: #4ade80; --ok-bg: #12331f; --warn: #fbbf24; --warn-bg: #3a2c0a; --bad: #f87171; --bad-bg: #3d1717; --info: #93c5fd; --info-bg: #162a4d;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); font-variant-numeric: tabular-nums; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
a { color: var(--brand); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

/* shell */
.app { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); padding: 16px 12px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; font-weight: 700; font-size: 18px; }
.logo { width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 800; }
.grp { margin: 14px 8px 4px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--mut); }
.nav a { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 10px; border-radius: var(--rc); color: var(--ink); text-decoration: none; }
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 10px 20px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top .sp { flex: 1; }
.menu-btn.ibtn { display: none; }
.who { display: flex; align-items: center; gap: 8px; }
.who select { min-height: 44px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--rc); background: var(--surface); }
.ibtn { min-width: 44px; min-height: 44px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: var(--rc); background: var(--surface); cursor: pointer; position: relative; }
.ibtn:hover { background: var(--surface-2); }
.dot { position: absolute; top: 8px; right: 8px; width: 9px; height: 9px; border-radius: 50%; background: var(--warn); border: 2px solid var(--surface); }
.sync { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer; font-size: 14px; }
.sync .d { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); }
.sync.off .d { background: var(--warn); }
main#view { padding: 20px; max-width: 1180px; width: 100%; margin: 0 auto; }
.crumb { color: var(--mut); font-size: 13px; margin-bottom: 4px; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.head .sub { color: var(--mut); font-size: 14px; margin-top: 2px; }
.acts { display: flex; flex-wrap: wrap; gap: 8px; }

/* controls */
.btn { min-height: 44px; padding: 8px 16px; border-radius: var(--rc); border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; transition: background .15s ease-out, transform .1s; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn.pri { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.pri:hover { filter: brightness(1.06); }
.btn.bad { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.field { display: grid; gap: 4px; }
.field label { font-size: 13px; color: var(--mut); }
.inp { min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--rc); background: var(--surface); width: 100%; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.chip { flex: none; min-height: 40px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.row .inp { max-width: 320px; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card > h2, .card > .ch { margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi b { display: block; font-size: 24px; line-height: 1.2; }
.kpi span { color: var(--mut); font-size: 13px; }
.kpi em { display: block; font-style: normal; font-size: 12px; margin-top: 4px; color: var(--mut); }
.kpi em.up { color: var(--ok); } .kpi em.down { color: var(--bad); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); } .pill.info { background: var(--info-bg); color: var(--info); }
.mut { color: var(--mut); } .num { text-align: right; } .big { font-size: 28px; font-weight: 700; }
.note { padding: 12px 14px; border-radius: var(--rc); background: var(--info-bg); color: var(--ink); border: 1px solid color-mix(in srgb, var(--info) 30%, transparent); font-size: 14px; }
.note.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.note.ok { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.empty { text-align: center; padding: 28px 12px; color: var(--mut); }

/* tables */
.tw { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--mut); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--surface-2); }
th.num, td.num { text-align: right; }
tfoot td { font-weight: 700; border-bottom: 0; }

/* bars + progress */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 8px; }
.bars div { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; height: 100%; font-size: 12px; color: var(--mut); }
.bars u { width: 100%; max-width: 44px; background: var(--brand); border-radius: 8px 8px 2px 2px; min-height: 4px; transition: height .3s ease-out; }
.bars div.today u { background: var(--warn); }
.bars b { color: var(--ink); font-size: 12px; font-weight: 600; }
.prog { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.prog i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.hbar { display: grid; grid-template-columns: 110px 1fr 70px; gap: 10px; align-items: center; margin: 8px 0; font-size: 14px; }
.hbar .prog { height: 12px; }

/* list rows */
.list { display: grid; }
.li { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.li:last-child { border-bottom: 0; }
.li .grow { flex: 1; min-width: 0; }
.li .t { font-weight: 600; } .li .s { color: var(--mut); font-size: 13px; }
.av { width: 38px; height: 38px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; flex: none; }

/* stepper */
.steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 4px 0 14px; }
.step { text-align: center; font-size: 12px; color: var(--mut); }
.step i { display: grid; place-items: center; width: 30px; height: 30px; margin: 0 auto 4px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); font-style: normal; font-weight: 700; }
.step.done i { background: var(--ok); border-color: var(--ok); color: #fff; }
.step.now i { border-color: var(--brand); color: var(--brand); }
.step.now { color: var(--ink); font-weight: 600; }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .h { text-align: center; font-size: 12px; color: var(--mut); padding: 4px 0; }
.cal .c { min-height: 52px; border-radius: 10px; padding: 4px 6px; font-size: 12px; border: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; justify-content: space-between; }
.cal .c b { font-size: 13px; }
.cal .c.P { background: var(--ok-bg); } .cal .c.A { background: var(--bad-bg); } .cal .c.L { background: var(--info-bg); }
.cal .c.W { background: var(--surface-2); color: var(--mut); } .cal .c.H { background: var(--warn-bg); } .cal .c.F { border-style: dashed; color: var(--mut); }
.cal .c.T { outline: 2px solid var(--brand); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; font-size: 13px; color: var(--mut); }
.legend span::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 6px; vertical-align: -1px; background: var(--surface-2); border: 1px solid var(--line); }
.legend .P::before { background: var(--ok-bg); } .legend .A::before { background: var(--bad-bg); } .legend .L::before { background: var(--info-bg); } .legend .H::before { background: var(--warn-bg); }

/* drawer + toast + sheet */
.scrim { position: fixed; inset: 0; background: rgba(5, 15, 18, .5); z-index: 40; animation: fade .15s ease-out; }
.drawer { position: fixed; z-index: 41; top: 0; right: 0; bottom: 0; width: min(460px, 100%); background: var(--surface); border-left: 1px solid var(--line); padding: 20px; overflow-y: auto; animation: slide .2s ease-out; }
.drawer .x { float: right; }
.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(var(--tab) + 16px); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); max-width: 92vw; animation: fade .15s ease-out; }
.tl { border-left: 2px solid var(--line); margin-left: 6px; padding-left: 14px; }
.tl div { position: relative; padding-bottom: 12px; font-size: 14px; }
.tl div::before { content: ""; position: absolute; left: -21px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }

/* bottom tabs (phone) */
.tabs { display: none; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, var(--brand-soft), var(--bg)); }
.login .card { width: min(420px, 100%); }
.roles { display: grid; gap: 8px; margin: 12px 0; }
.role { display: flex; gap: 12px; align-items: center; min-height: 56px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--rc); background: var(--surface); cursor: pointer; text-align: left; width: 100%; }
.role:hover { border-color: var(--brand); }

@media (max-width: 900px) {
  .g2, .g3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { display: block; }
  .side { display: none; }
  .menu-btn.ibtn { display: inline-grid; }
  main#view { padding: 14px 14px calc(var(--tab) + 24px); }
  .top { padding: 8px 14px; }
  .tabs { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: var(--tab); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); }
  .tabs a, .tabs button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 0; background: none; color: var(--mut); text-decoration: none; font-size: 12px; min-height: 44px; cursor: pointer; }
  .tabs [aria-current="page"] { color: var(--brand); font-weight: 700; }
  .who span, .sync .lbl { display: none; }
  .top { gap: 6px; }
  .top .brand { display: none; }
  .who { flex: 1 1 0; min-width: 0; }
  .who select { width: 100%; min-width: 0; max-width: 100%; text-overflow: ellipsis; }
  .steps .step { font-size: 11px; }
}
.sheet { position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; max-height: 82vh; overflow-y: auto; background: var(--surface); border-radius: 20px 20px 0 0; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); animation: rise .2s ease-out; }
.sheet .nav a { min-height: 48px; }
@media (max-width: 640px) {
  .rt thead { display: none; }
  .rt tr { display: block; border: 1px solid var(--line); border-radius: var(--rc); padding: 8px 10px; margin-bottom: 10px; background: var(--surface); }
  .rt td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 4px 0; text-align: right; }
  .rt td::before { content: attr(data-l); color: var(--mut); font-size: 13px; text-align: left; }
  .rt td.num { text-align: right; }
  .drawer { top: auto; width: 100%; max-height: 88vh; border-radius: 20px 20px 0 0; border-left: 0; animation: rise .2s ease-out; }
  .hbar { grid-template-columns: 88px 1fr 60px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
