/* Layout for the working app. Visual rules come from ../design (tokens + components). */

.form-error { color: var(--c-absent); font-size: var(--text-sm); }
.dialog.wide { width: min(720px, calc(100vw - 32px)); }
.dialog-body { max-height: calc(100vh - 180px); overflow: auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3) var(--space-4); }
.form-grid .span { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--c-ink); }
textarea.input { height: auto; min-height: 72px; padding: var(--space-2) var(--space-3); resize: vertical; }
.input[type=date], .input[type=time], .input[type=month] { font-variant-numeric: tabular-nums; }
@media (max-width: 575px) { .form-grid { grid-template-columns: 1fr; } .form-grid > span:empty { display: none; } }
.table td.num { white-space: nowrap; }

.kv { display: flex; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: var(--line) solid var(--c-line); }
.kv > :first-child { color: var(--c-muted); }
.empty { padding: var(--space-6) 0; color: var(--c-muted); }
.hint { font-size: var(--text-xs); color: var(--c-muted); }
.pill-count { font-size: var(--text-xs); color: var(--c-muted); margin-left: 3px; }
.danger-text { color: var(--c-absent); }
.ok-text { color: var(--c-present); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.person { display: flex; align-items: center; gap: var(--space-3); }
.acts { display: flex; gap: var(--space-1); justify-content: flex-end; }
a.person:hover { text-decoration: none; }
a.person:hover b { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.icon-btn { width: var(--control); height: var(--control); display: inline-grid; place-items: center; background: none; border: 0; cursor: pointer; color: var(--c-ink); position: relative; flex: none; }
.icon-btn:hover { background: var(--c-quiet); }
.icon-btn .badge { position: absolute; top: 8px; right: 8px; min-width: 6px; height: 6px; border-radius: 50%; background: var(--c-active); }
.loading { padding: var(--space-9) 0; text-align: center; color: var(--c-muted); }

/* ---------- Admin shell ---------- */
.topbar { border-bottom: var(--line) solid var(--c-line); background: var(--c-page); position: sticky; top: 0; z-index: 5; }
.topbar .header { justify-content: space-between; }
.topbar .nav { flex: 1; }
.tools { display: flex; align-items: center; gap: var(--space-2); }
.tools .search { width: 200px; }
.me-chip { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--c-muted); background: none; border: 0; cursor: pointer; padding: 4px; }
.me-chip:hover { color: var(--c-ink); }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-4); padding: var(--space-7) 0 var(--space-5); flex-wrap: wrap; }
.page-head h1 { margin-top: var(--space-1); }
.page-head .actions { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3) var(--space-4); padding-bottom: var(--space-4); flex-wrap: wrap; }
.toolbar .search { width: 240px; }
.toolbar .group { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.pager { display: flex; align-items: center; gap: var(--space-1); }
.pager .input { width: auto; }
main.container { padding-bottom: var(--space-9); }
.split { display: grid; grid-template-columns: minmax(0, 8fr) minmax(0, 4fr); gap: var(--space-8); }
.aside > section + section { margin-top: var(--space-7); }
section + section.block, .block + .block { margin-top: var(--space-7); }

.summary { display: grid; grid-template-columns: 1.4fr repeat(5, 1fr); border-top: var(--line) solid var(--c-line-strong); border-bottom: var(--line) solid var(--c-line); margin-bottom: var(--space-7); }
.summary.cols-4 { grid-template-columns: repeat(4, 1fr); }
.summary > * { all: unset; display: grid; gap: var(--space-2); align-content: start; padding: var(--space-4) var(--space-4) var(--space-5); border-left: var(--line) solid var(--c-line); position: relative; }
.summary > button { cursor: pointer; }
.summary > *:first-child { border-left: 0; padding-left: 0; }
.summary > button:hover { background: var(--c-surface); }
.summary > button:focus-visible { outline: 2px solid var(--c-focus); outline-offset: -2px; }
.summary > [aria-pressed="true"]::after { content: ""; position: absolute; left: var(--space-4); right: var(--space-4); bottom: -1px; height: 1px; background: var(--c-active); }
.summary > :first-child[aria-pressed="true"]::after { left: 0; }
.summary .of { font-size: var(--text-md); color: var(--c-faint); }

.req { display: grid; gap: var(--space-2); padding: var(--space-4) 0; border-bottom: var(--line) solid var(--c-line); }
.req-top { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); }
.req-actions { display: flex; gap: var(--space-2); margin-top: var(--space-1); flex-wrap: wrap; }

.profile-head { display: flex; gap: var(--space-5); align-items: center; padding: var(--space-7) 0 var(--space-5); flex-wrap: wrap; }
.profile-head .avatar { width: 96px; height: 96px; font-size: var(--text-xl); }
.profile-head .grow { flex: 1; min-width: 200px; }
.cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-7); }

/* Month grid: people x days with status dots. */
.mgrid { border-collapse: collapse; font-size: var(--text-xs); }
.mgrid th, .mgrid td { padding: 0; text-align: center; border-bottom: var(--line) solid var(--c-line); height: 34px; min-width: 26px; }
.mgrid th { color: var(--c-muted); font-weight: 400; vertical-align: bottom; padding-bottom: 6px; }
.mgrid th.off { color: var(--c-faint); }
.mgrid th.today { color: var(--c-ink); box-shadow: inset 0 -2px 0 var(--c-ink); }
.mgrid td.name, .mgrid th.name { text-align: left; min-width: 170px; padding-right: var(--space-3); position: sticky; left: 0; background: var(--c-page); z-index: 1; }
.mgrid td.off { background: var(--c-surface); }
.mgrid td button { all: unset; cursor: pointer; display: grid; place-items: center; width: 100%; height: 100%; }
.mgrid td button:hover { background: var(--c-quiet); }
.mgrid td button:focus-visible { outline: 2px solid var(--c-focus); outline-offset: -2px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--c-faint); }
.dot[data-s="present"] { background: var(--c-present); }
.dot[data-s="late"] { background: var(--c-late); }
.dot[data-s="absent"] { background: var(--c-absent); }
.dot[data-s="leave"] { background: var(--c-leave); }
.dot[data-s="none"] { background: transparent; box-shadow: inset 0 0 0 1px var(--c-line); }
.dot[data-s="open"] { background: transparent; box-shadow: inset 0 0 0 1.5px var(--c-late); }
.legend { display: flex; gap: var(--space-4); flex-wrap: wrap; font-size: var(--text-xs); color: var(--c-muted); padding-top: var(--space-3); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Calendar for one person's month. */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); border-top: var(--line) solid var(--c-line); }
.cal > div { min-height: 58px; padding: 6px; border-bottom: var(--line) solid var(--c-line); display: grid; align-content: space-between; font-size: var(--text-xs); }
.cal .h { color: var(--c-muted); min-height: auto; padding: 6px; }
.cal .off { background: var(--c-surface); color: var(--c-faint); }
.cal .t { box-shadow: inset 0 2px 0 var(--c-ink); }

@media (max-width: 1199px) { .tools .search { display: none; } }
@media (max-width: 991px) {
  .topbar .header { flex-wrap: wrap; height: auto; padding: var(--space-3) 0 0; row-gap: 0; }
  .topbar .nav { order: 3; flex-basis: 100%; overflow-x: auto; padding: var(--space-3) 0; gap: var(--space-5); scrollbar-width: none; }
  .split { grid-template-columns: 1fr; gap: var(--space-7); }
  .summary { grid-template-columns: repeat(3, 1fr); }
  .summary > :nth-child(4) { border-left: 0; padding-left: 0; }
  .summary > :nth-child(-n+3) { border-bottom: var(--line) solid var(--c-line); }
  .summary.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .summary.cols-4 > :nth-child(3) { border-left: 0; padding-left: 0; }
  .summary.cols-4 > :nth-child(4) { border-left: var(--line) solid var(--c-line); padding-left: var(--space-4); }
  .cols-3 { grid-template-columns: 1fr; }
}
@media (max-width: 767px) {
  .section-head { flex-wrap: wrap; row-gap: var(--space-1); }
  .pager span.num { min-width: 110px !important; }
  .me-chip span.name { display: none; }
  .page-head { padding-top: var(--space-6); }
  .summary > * { padding: var(--space-3) var(--space-3) var(--space-4); gap: var(--space-1); }
  .summary .figure-lg { font-size: var(--text-xl); }
  .summary .of { font-size: var(--text-sm); }
  .toolbar .search { width: 100%; }
  .hide-sm { display: none !important; }
  .table th, .table td { padding-left: var(--space-2) !important; padding-right: var(--space-2) !important; }
  .table th:first-child, .table td:first-child { padding-left: 0 !important; }
  .table th:last-child, .table td:last-child { padding-right: 0 !important; }
  .acts { flex-direction: column; align-items: flex-end; }
  .person { gap: var(--space-2); }
  .profile-head .avatar { width: 72px; height: 72px; }
}
@media (min-width: 768px) { .show-sm { display: none !important; } }
@media (max-width: 400px) {
  .hide-xs { display: none !important; }
  .summary .figure { font-size: var(--text-lg); }
  .cal > div { padding: 4px 2px; min-height: 50px; }
  .cal .num { font-size: 11px; }
}

/* ---------- Employee app ---------- */
.emp { max-width: 480px; margin: 0 auto; padding: 0 var(--page-pad) calc(var(--tabbar) + var(--space-7)); }
.emp .top { display: flex; align-items: center; justify-content: space-between; height: var(--header); }
.lang { display: flex; align-items: center; gap: 2px; font-size: var(--text-xs); }
.lang button { background: none; border: 0; padding: 4px 3px; cursor: pointer; color: var(--c-muted); }
.lang button[aria-pressed="true"] { color: var(--c-active); font-weight: var(--font-weight-strong); }
.lang i { color: var(--c-faint); font-style: normal; }
.emp .hello { padding: var(--space-5) 0 var(--space-6); }
.emp .hello h1 { margin-top: var(--space-1); }
.me-row { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-5); }
.times { display: grid; grid-template-columns: repeat(3, 1fr); border-top: var(--line) solid var(--c-line-strong); border-bottom: var(--line) solid var(--c-line); }
.times > div { padding: var(--space-4) 0; }
.times > div + div { padding-left: var(--space-4); border-left: var(--line) solid var(--c-line); }
.times .figure { margin-top: var(--space-1); }
.where { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-4) 0; }
.where .i { color: var(--c-site); margin-top: 1px; }
.where b { font-weight: 400; color: var(--c-ink); display: block; }
.leave-row { display: grid; grid-template-columns: 1fr auto; row-gap: var(--space-2); padding: var(--space-3) 0; border-bottom: var(--line) solid var(--c-line); }
.leave-row .meter { grid-column: 1 / -1; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); margin-top: var(--space-3); }
.week > div { display: grid; gap: var(--space-2); justify-items: start; padding: var(--space-2) 0; border-top: 2px solid transparent; }
.week > div.is-today { border-top-color: var(--c-ink); }
.week .d { font-size: var(--text-xs); color: var(--c-muted); }
.week .h { font-size: var(--text-sm); color: var(--c-ink); }
.banner { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) 0; border-bottom: var(--line) solid var(--c-line); }
.banner .grow { flex: 1; }
@media (min-width: 481px) { .tabbar { grid-template-columns: repeat(4, 120px); justify-content: center; } }
.tabbar .avatar { outline: 1px solid transparent; outline-offset: 1px; }
.tabbar a[aria-current="page"] .avatar { outline-color: var(--c-ink); }

/* ---------- Sign-in ---------- */
.signin { min-height: 100vh; display: grid; place-items: center; padding: var(--space-6) var(--page-pad); }
.signin form { width: min(360px, 100%); display: grid; gap: var(--space-4); }
.signin .brand img { height: 40px; }

@media print {
  .topbar, .tabbar, .no-print, .toast { display: none !important; }
  body { background: #fff; color: #000; }
}
