:root {
  --bg: #f2f5f9;
  --surface: #ffffff;
  --ink: #20283a;
  --muted: #5f6b7d;
  --line: #d8dee7;
  --brand: #afc32e;
  --brand-dark: #7f921f;
  --brand-soft: #eef5c8;
  --section-blue: #3f4d68;
  --blue: #455a7c;
  --blue-dark: #2a3042;
  --blue-soft: #edf3fb;
  --blue-line: #c9d5e7;
  --nav: #2a3042;
  --warn: #687a92;
  --danger: #b44b4b;
  --ok: #355f86;
  --focus: #5b7298;
  --shadow: 0 18px 50px rgba(42, 48, 66, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

[hidden] {
  display: none !important;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(42, 48, 66, 0.84), rgba(42, 48, 66, 0.84)),
    url("https://www.irastorza.com/wp-content/uploads/2018/02/irastorza-carpinteria-integral.jpg");
  background-size: cover;
  background-position: center;
}

.login-panel {
  width: min(430px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  background: rgba(255, 255, 255, 0.96);
  border-top: 6px solid var(--blue);
  box-shadow: var(--shadow);
}

.login-brand {
  align-items: start;
  width: fit-content;
  padding: 16px 18px;
  background: var(--nav);
  border-bottom: 4px solid var(--brand);
}

.login-panel h1 {
  font-size: 1.8rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(18px, 5vw, 64px);
  background: var(--nav);
  color: #fff;
  border-bottom: 3px solid var(--brand);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  display: block;
  width: clamp(150px, 18vw, 235px);
  height: auto;
  object-fit: contain;
}

.brand span {
  display: block;
  color: #dce3ea;
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: lowercase;
}

.status-pill {
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 0.82rem;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.08);
}

.session-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.session-box span {
  color: #fff;
  font-weight: 800;
}

.main-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.tab {
  min-height: 64px;
  border: 0;
  border-right: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-weight: 700;
}

.tab.is-active {
  color: #fff;
  background: var(--blue);
  box-shadow: inset 0 -3px 0 var(--brand);
}

main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 3vw, 34px);
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.55rem, 3vw, 2.45rem);
}

h2 {
  font-size: 1.05rem;
}

.date-chip {
  padding: 9px 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-weight: 700;
}

.compact-field {
  min-width: 180px;
  max-width: 220px;
}

.entry-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
}

.stepper {
  position: sticky;
  top: 70px;
  display: grid;
  gap: 10px;
}

.step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
}

.step span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  background: var(--blue-soft);
  color: var(--muted);
  font-weight: 800;
}

.step p {
  margin: 0;
  font-weight: 700;
}

.step.is-active {
  border-color: var(--blue);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.step.is-active span {
  background: var(--blue);
  color: #fff;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.form-section,
.panel {
  padding: clamp(16px, 2.4vw, 24px);
}

.form-section + .form-section {
  border-top: 1px solid var(--line);
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.section-title span {
  color: var(--muted);
  font-size: 0.9rem;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #a9b4c4;
  background: #fff;
  color: var(--ink);
  padding: 12px;
  min-height: 46px;
  border-radius: 6px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(69, 90, 124, 0.24);
  border-color: var(--focus);
}

.helper-box {
  margin-top: 12px;
  padding: 12px;
  background: var(--blue-soft);
  border-left: 4px solid var(--blue);
  color: var(--nav);
  line-height: 1.4;
  opacity: 1;
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.helper-box.is-fading,
.save-bubble.is-fading {
  opacity: 0;
  transform: translateY(-4px);
}

.worker-identity {
  display: grid;
  gap: 4px;
  padding: 14px 0 4px;
}

.worker-identity strong {
  color: var(--ink);
  font-size: clamp(1.45rem, 3vw, 2.2rem);
  line-height: 1.05;
}

.worker-identity span {
  color: var(--muted);
  font-weight: 800;
}

.worker-select-row[hidden] + .helper-box {
  margin-top: 8px;
}

.entry-lock {
  margin-top: 14px;
  padding: clamp(18px, 3vw, 28px);
  border: 2px solid #a9b4c4;
  border-left: 8px solid var(--warn);
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--nav);
}

.entry-lock strong {
  display: block;
  margin-bottom: 8px;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.1;
}

.entry-lock span {
  display: block;
  font-size: 1rem;
  line-height: 1.45;
}

.task-picker {
  display: grid;
  gap: 10px;
}

.task-browser {
  grid-template-columns: minmax(210px, 300px) minmax(0, 1fr);
  align-items: start;
}

.task-menu-panel {
  height: 360px;
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 8px;
}

.task-menu-panel h3 {
  margin: 6px 4px 8px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.task-menu {
  display: grid;
  gap: 8px;
}

.task-type-menu {
  margin-bottom: 14px;
}

.task-menu button {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
  text-align: left;
}

.task-menu button.is-active {
  background: var(--section-blue);
  border-color: var(--section-blue);
  color: #fff;
}

.task-search-panel {
  display: grid;
  gap: 10px;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-height: 360px;
}

.task-filter-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.compact-search {
  max-width: 440px;
}

.task-results,
.approval-list {
  display: grid;
  gap: 8px;
}

.task-results {
  height: 292px;
  overflow: auto;
  align-content: start;
  padding-right: 4px;
}

.empty-state {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: #fff;
  font-weight: 700;
}

.approval-alert {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid #a9b4c4;
  border-left: 5px solid var(--warn);
  border-radius: 6px;
  background: var(--blue-soft);
  color: var(--nav);
  line-height: 1.35;
}

.approval-alert strong {
  display: block;
  margin-bottom: 4px;
}

.task-result,
.line-row,
.approval-card {
  border: 1px solid var(--line);
  background: #f8fafc;
  padding: 12px;
}

.task-result {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  border-radius: 6px;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.task-result.is-clicked {
  border-color: var(--blue-dark);
  background: var(--blue-dark);
  color: #fff;
  transform: translateY(1px);
}

.task-result.is-clicked span,
.task-result.is-clicked strong {
  color: #fff;
}

.task-result strong,
.line-row strong {
  display: block;
}

.task-result span,
.line-row span,
.approval-card span {
  color: var(--muted);
  font-size: 0.86rem;
}

.task-lines {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.admin-password-panel {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 10px 12px;
}

.admin-password-panel strong {
  display: block;
  margin-bottom: 8px;
  font-weight: 800;
}

.admin-password-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.line-row {
  display: grid;
  grid-template-columns: minmax(210px, 0.9fr) minmax(260px, 1.2fr) 120px 38px;
  gap: 10px;
  align-items: end;
  border-radius: 6px;
}

.line-row.is-new-line {
  animation: line-added 1.15s ease;
}

@keyframes line-added {
  0% {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(175, 195, 46, 0.22);
    background: #f5fad9;
  }
  45% {
    opacity: 1;
    transform: translateY(0) scale(1);
    border-color: var(--brand);
    box-shadow: 0 12px 28px rgba(69, 90, 124, 0.16);
    background: #f5fad9;
  }
  100% {
    opacity: 1;
    transform: none;
    box-shadow: none;
  }
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--danger);
  font-weight: 800;
}

.totals-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.totals-grid div {
  padding: 14px;
  border: 1px solid var(--line);
  background: #f8fafc;
}

.totals-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 6px;
}

.totals-grid strong {
  font-size: 1.5rem;
}

.checks {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.check-row {
  grid-template-columns: auto 1fr;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #f8fafc;
}

.check-row input {
  width: 20px;
  min-height: 20px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.primary-action,
.secondary-action {
  min-height: 44px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 800;
}

.primary-action {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.primary-action:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

.primary-action:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.secondary-action {
  background: #fff;
  color: var(--nav);
  border-color: var(--blue-line);
}

.save-bubble {
  position: fixed;
  right: clamp(16px, 4vw, 36px);
  bottom: 22px;
  z-index: 40;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 999px;
  background: var(--nav);
  color: #fff;
  font-weight: 800;
  box-shadow: var(--shadow);
  opacity: 1;
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.summary-toolbar,
.settings-grid,
.approval-grid {
  display: grid;
  gap: 16px;
}

.summary-toolbar {
  grid-template-columns: minmax(240px, 1fr) 160px 170px auto;
  align-items: end;
  margin-bottom: 16px;
}

.date-grid {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(220px, 1fr);
  gap: 12px;
  align-items: end;
}

.date-flags {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 10px;
}

.file-loader input {
  padding: 10px;
}

.readonly-field {
  display: grid;
  gap: 7px;
  min-height: 46px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.readonly-field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.matrix-line {
  display: grid;
  grid-template-columns: 110px 1fr 74px;
  gap: 8px;
  align-items: start;
  padding: 5px 0;
}

.matrix-line + .matrix-line {
  border-top: 1px solid var(--line);
}

.matrix-line span {
  color: var(--ink);
}

.task-detail-line {
  padding: 4px 0;
  line-height: 1.35;
}

.task-detail-line + .task-detail-line {
  border-top: 1px solid var(--line);
}

del {
  display: inline-block;
  margin-bottom: 2px;
  color: var(--danger);
  text-decoration-thickness: 2px;
}

.matrix-line em {
  color: var(--muted);
  font-style: normal;
  font-weight: 800;
  text-align: right;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
}

.excel-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: #fff;
}

.excel-table th,
.excel-table td {
  border: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

.excel-table th {
  background: var(--blue-soft);
  color: var(--nav);
}

.missing {
  color: var(--danger);
  font-weight: 800;
}

.ok {
  color: var(--ok);
  font-weight: 800;
}

.warn {
  color: var(--warn);
  font-weight: 800;
}

.approval-grid,
.settings-grid {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.9fr);
  align-items: start;
}

.approval-calendar-panel {
  margin-bottom: 16px;
}

.approval-calendar {
  display: grid;
  grid-template-columns: 124px minmax(0, 1fr) 124px;
  gap: 18px;
  align-items: stretch;
  margin-bottom: 12px;
}

.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(72px, 1fr));
  gap: 10px;
}

.approval-calendar button {
  min-height: 66px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: var(--ink);
  text-align: left;
}

.approval-calendar .calendar-nav {
  min-width: 0;
  border-radius: 999px;
  border-color: var(--nav);
  background: var(--nav);
  color: #fff;
  text-align: center;
  font-weight: 800;
  align-self: center;
  min-height: 48px;
  box-shadow: 0 8px 18px rgba(15, 22, 29, 0.12);
}

.approval-calendar .calendar-nav-prev {
  margin-right: 8px;
}

.approval-calendar .calendar-nav-next {
  margin-left: 8px;
}

.approval-calendar button strong,
.approval-calendar button span,
.approval-calendar button small {
  display: block;
}

.approval-calendar button small {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.approval-calendar button span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.approval-calendar .calendar-nav span {
  margin-top: 0;
  color: inherit;
  font-size: 1rem;
}

.approval-calendar button.is-active {
  border-color: var(--blue-dark);
  background: var(--blue-dark);
  color: #fff;
}

.approval-calendar button.is-active span,
.approval-calendar button.is-active small {
  color: #eef4ff;
}

.approval-calendar button.is-muted {
  border-color: var(--blue-line);
  background: var(--blue-soft);
}

.approval-calendar button.has-review {
  border-color: var(--brand);
  box-shadow: inset 0 0 0 2px rgba(175, 195, 46, 0.4);
}

.approval-calendar button.has-review span {
  color: var(--blue-dark);
}

.pending-review-days {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding-top: 4px;
}

.pending-review-days > strong {
  color: var(--blue-dark);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.pending-review-days > div {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.pending-review-days button {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 7px 10px;
  border-color: var(--blue-line);
  background: var(--blue-soft);
}

.pending-review-days button.is-current {
  border-color: var(--blue-dark);
  background: var(--blue-dark);
  color: #fff;
}

.pending-review-days button span,
.pending-review-days button small {
  display: inline;
  margin: 0;
}

.pending-review-days button small {
  margin-left: 6px;
  color: inherit;
  font-size: 0.72rem;
  opacity: 0.78;
}

.guest-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.guest-form .section-title,
.guest-form .helper-box {
  grid-column: 1 / -1;
}

.users-panel {
  grid-column: 1 / -1;
}

.projects-panel {
  grid-column: 1 / -1;
}

.processes-panel {
  grid-column: 1 / -1;
}

.rules-panel {
  grid-column: 1 / -1;
}

.settings-rule-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 180px auto;
  gap: 10px;
  align-items: end;
}

.process-toolbar,
.user-form,
.project-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 260px);
  gap: 10px;
  margin-bottom: 12px;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.tag-cloud span,
.table-tag {
  display: inline-block;
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-size: 0.82rem;
  font-weight: 800;
}

.process-table-wrap {
  max-height: 430px;
}

.process-table {
  min-width: 980px;
}

.process-table tr.is-inactive {
  background: #4a5570;
  color: #f4f6f8;
}

.process-table tr.is-inactive td,
.process-table tr.is-inactive strong {
  color: #f4f6f8;
}

.process-table tr.is-inactive .table-tag,
.process-table tr.is-inactive .secondary-action {
  border-color: var(--nav);
  background: var(--nav);
  color: #fff;
}

.advanced-yaml {
  margin-top: 14px;
}

.advanced-yaml summary {
  cursor: pointer;
  color: var(--section-blue);
  font-weight: 800;
  margin-bottom: 10px;
}

.user-list {
  display: grid;
  gap: 10px;
}

.project-list {
  display: grid;
  gap: 10px;
}

.user-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.project-form {
  grid-template-columns: minmax(160px, 220px) minmax(220px, 1fr) auto;
}

.permission-editor {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.permission-editor strong {
  color: var(--ink);
}

.permission-tags,
.selected-permissions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.permission-tags {
  max-height: 160px;
  overflow: auto;
  padding: 2px;
}

.permission-tags button,
.selected-permissions span {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
}

.permission-tags button span {
  margin-right: 6px;
  color: var(--section-blue);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.permission-tags button.is-active {
  border-color: var(--section-blue);
  background: var(--section-blue);
  color: #fff;
}

.permission-tags button.is-active span {
  color: #dce7f7;
}

.selected-permissions {
  min-height: 38px;
  align-items: center;
  color: var(--muted);
}

.selected-permissions span {
  border-color: var(--blue-line);
  background: var(--blue-soft);
  color: var(--blue-dark);
}

.danger-action {
  border-color: #e0b8b8;
  color: var(--danger);
}

.user-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.user-row span {
  color: var(--muted);
  line-height: 1.35;
}

.user-row strong {
  display: block;
  color: var(--ink);
}

.user-row.is-inactive {
  opacity: 0.68;
  background: #eef1f5;
}

.fatal-error {
  max-width: 760px;
  margin: 60px auto;
  padding: 24px;
  background: #fff;
  border: 1px solid var(--line);
}

.approval-card {
  display: grid;
  gap: 10px;
  border-radius: 6px;
}

.approval-card.is-muted {
  background: var(--blue-soft);
}

.approval-card p {
  margin: 0;
  color: var(--muted);
}

.approval-card header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.approval-project-group {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 6px;
  background: #f8fafc;
}

.approval-project-group header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.approval-project-group header strong {
  color: var(--ink);
  line-height: 1.25;
}

.approval-project-group header span {
  color: var(--blue);
  font-weight: 800;
  white-space: nowrap;
}

.approval-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 9px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
}

.approval-line span strong {
  display: block;
  margin-bottom: 4px;
}

.line-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.admin-editor.empty {
  color: var(--muted);
}

.admin-editor {
  display: grid;
  gap: 12px;
}

.guide-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.guide-card {
  display: grid;
  align-content: start;
  gap: 14px;
}

.guide-card h2 {
  font-size: 1.2rem;
}

.guide-steps,
.guide-tips {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 20px;
}

.guide-steps li,
.guide-tips li {
  color: var(--muted);
  line-height: 1.38;
}

.guide-steps strong,
.guide-tips strong,
.status-guide strong {
  color: var(--ink);
}

.guide-steps span,
.status-guide span {
  display: block;
  margin-top: 3px;
}

.status-guide {
  display: grid;
  gap: 9px;
}

.status-guide div {
  padding: 11px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  background: #f8fafc;
  border-radius: 6px;
  color: var(--muted);
  line-height: 1.35;
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
  }

  .brand strong {
    font-size: 1.2rem;
  }

  .topbar .status-pill {
    display: none;
  }

  main {
    padding: 14px;
  }

  .page-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .compact-field {
    max-width: none;
  }

  .entry-layout,
  .approval-grid,
  .settings-grid,
  .date-grid,
  .summary-toolbar,
  .guest-form,
  .project-form,
  .user-form {
    grid-template-columns: 1fr;
  }

  .task-browser {
    grid-template-columns: 1fr;
  }

  .approval-calendar {
    grid-template-columns: repeat(2, 1fr);
  }

  .approval-calendar .calendar-nav {
    min-width: 0;
    grid-row: 1;
  }

  .calendar-days {
    grid-column: 1 / -1;
    grid-row: 2;
    grid-template-columns: repeat(7, minmax(86px, 1fr));
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .task-menu-panel {
    height: 180px;
    max-height: 180px;
  }

  .task-search-panel {
    min-height: 320px;
  }

  .task-filter-row {
    grid-template-columns: 1fr;
  }

  .admin-password-grid {
    grid-template-columns: 1fr;
  }

  .task-results {
    height: 250px;
  }

  .process-toolbar,
  .user-form {
    grid-template-columns: 1fr;
  }

  .stepper {
    position: static;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  .step {
    display: grid;
    justify-items: center;
    text-align: center;
    padding: 8px 4px;
  }

  .step p {
    font-size: 0.74rem;
  }

  .section-title {
    display: block;
  }

  .section-title h2 {
    margin-bottom: 4px;
  }

  .line-row {
    grid-template-columns: 1fr;
  }

  .matrix-line {
    grid-template-columns: 1fr;
  }

  .matrix-line em {
    text-align: left;
  }

  .approval-line {
    grid-template-columns: 1fr;
  }

  .guide-layout {
    grid-template-columns: 1fr;
  }

  .line-actions {
    justify-content: stretch;
  }

  .line-actions button {
    flex: 1 1 130px;
  }

  .user-row {
    grid-template-columns: 1fr;
  }

  .checks,
  .totals-grid {
    grid-template-columns: 1fr;
  }

  .main-tabs {
    overflow-x: auto;
  }

  .tab {
    min-width: 94px;
  }
}

@media (max-width: 900px) {
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  body {
    overflow-x: hidden;
  }

  .topbar {
    gap: 10px;
    padding: 10px 14px;
  }

  .brand {
    gap: 8px;
    flex: 1 1 auto;
    overflow: hidden;
  }

  .brand-logo {
    width: clamp(128px, 34vw, 190px);
  }

  .brand span {
    max-width: 88px;
    font-size: 0.72rem;
    line-height: 1.05;
  }

  .session-box {
    flex: 0 0 auto;
    gap: 8px;
  }

  .session-box span {
    font-size: 0.86rem;
  }

  .session-box .secondary-action {
    min-height: 42px;
    padding-inline: 14px;
  }

  .main-tabs {
    position: static;
    grid-auto-flow: column;
    grid-auto-columns: minmax(112px, 1fr);
    grid-template-columns: none;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .main-tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    min-height: 54px;
    min-width: 112px;
    padding: 0 14px;
    white-space: nowrap;
  }

  main {
    width: 100%;
    padding: 16px;
  }

  .page-heading {
    gap: 12px;
    margin-bottom: 14px;
  }

  h1 {
    font-size: clamp(1.65rem, 7vw, 2.15rem);
    line-height: 1.08;
  }

  h2 {
    font-size: 1.12rem;
  }

  .panel {
    box-shadow: 0 10px 26px rgba(42, 48, 66, 0.08);
  }

  .form-section,
  .panel {
    padding: 16px;
  }

  .section-title {
    display: grid;
    gap: 4px;
  }

  .section-title span {
    font-size: 0.88rem;
    line-height: 1.35;
  }

  input,
  select,
  textarea {
    min-height: 44px;
    padding: 10px 11px;
    font-size: 16px;
  }

  .primary-action,
  .secondary-action {
    min-height: 44px;
  }

  .summary-toolbar,
  .date-grid,
  .task-filter-row,
  .approval-grid,
  .settings-grid,
  .settings-rule-grid,
  .process-toolbar,
  .project-form,
  .user-form,
  .admin-password-grid,
  .guest-form {
    grid-template-columns: 1fr;
  }

  .summary-toolbar {
    gap: 12px;
  }

  #send-summary {
    width: 100%;
  }

  .table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .excel-table {
    min-width: 640px;
    font-size: 0.86rem;
  }

  .process-table {
    min-width: 720px;
  }

  .process-table-wrap {
    max-height: 320px;
    overflow: auto;
  }

  .approval-calendar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .approval-calendar .calendar-nav {
    grid-row: 1;
    margin: 0;
    min-height: 46px;
  }

  .calendar-days {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 2px 8px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  .approval-calendar button:not(.calendar-nav) {
    flex: 0 0 calc((100% - 32px) / 5);
    min-width: 66px;
    min-height: 68px;
    scroll-snap-align: start;
  }

  .pending-review-days {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
  }

  .pending-review-days > div {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .pending-review-days button {
    flex: 0 0 auto;
    min-height: 40px;
  }

  #mark-non-computable {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 8px 10px;
  }

  .brand-logo {
    width: 132px;
  }

  .topbar .brand span {
    display: none;
  }

  .session-box span {
    display: none;
  }

  .session-box .secondary-action {
    min-width: 72px;
    padding-inline: 12px;
  }

  main {
    padding: 12px 10px 24px;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .page-heading {
    display: grid;
    align-items: stretch;
  }

  .date-chip {
    padding: 10px 12px;
    font-size: 0.92rem;
  }

  .panel {
    border-radius: 0;
    box-shadow: none;
  }

  .form-section,
  .panel {
    padding: 14px;
  }

  #view-summary .panel,
  #view-settings .panel,
  #view-approval .panel {
    padding: 12px;
  }

  #view-summary .page-heading,
  #view-settings .page-heading,
  #view-approval .page-heading {
    margin-bottom: 10px;
  }

  #summary-title,
  #settings-title,
  #approval-title {
    font-size: 1.65rem;
  }

  #view-summary .summary-toolbar {
    gap: 10px;
  }

  #summary-date,
  #approval-date {
    min-height: 40px;
    height: 40px;
    padding: 7px 10px;
    font-size: 0.95rem;
    line-height: 1.1;
  }

  #summary-mode {
    min-height: 42px;
    height: 42px;
    font-size: 1rem;
  }

  #view-summary .table-wrap {
    margin-top: 2px;
  }

  #view-summary .excel-table {
    min-width: 520px;
    font-size: 0.78rem;
  }

  #view-summary .excel-table th,
  #view-summary .excel-table td {
    padding: 7px;
  }

  #view-settings .section-title span {
    font-size: 0.82rem;
  }

  #view-settings .process-toolbar {
    gap: 8px;
    margin-bottom: 8px;
  }

  #view-settings .tag-cloud {
    gap: 6px;
    margin-bottom: 8px;
  }

  #view-settings .tag-cloud span,
  #view-settings .table-tag {
    padding: 4px 7px;
    font-size: 0.72rem;
  }

  #view-settings .process-table-wrap {
    max-height: 260px;
    overflow: auto;
  }

  #view-settings .process-table {
    min-width: 620px;
    font-size: 0.74rem;
  }

  #view-settings .process-table th,
  #view-settings .process-table td {
    padding: 6px;
  }

  #view-settings .file-loader {
    margin-top: 8px;
    font-size: 0.86rem;
  }

  #view-settings .actions {
    gap: 8px;
  }

  #view-settings,
  #view-settings .settings-grid,
  #view-settings .users-panel,
  #view-settings .user-form,
  #view-settings .user-list,
  #view-settings .user-row,
  #view-settings .permission-editor,
  #view-settings .admin-password-panel,
  #view-settings .admin-password-grid {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  #view-settings .settings-grid {
    overflow: hidden;
  }

  #view-settings .users-panel {
    overflow: hidden;
  }

  #view-settings .user-form {
    gap: 8px;
  }

  #view-settings .permission-editor {
    padding: 10px;
    overflow: hidden;
  }

  #view-settings .permission-tags,
  #view-settings .selected-permissions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 7px;
    max-width: 100%;
  }

  #view-settings .permission-tags {
    max-height: 230px;
    overflow-y: auto;
    overflow-x: hidden;
  }

  #view-settings .permission-tags button,
  #view-settings .selected-permissions span {
    width: 100%;
    max-width: 100%;
    min-height: 38px;
    border-radius: 6px;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  #view-settings .permission-tags button span {
    display: inline;
    margin-right: 5px;
  }

  #view-settings .admin-password-panel {
    padding: 10px;
    overflow: hidden;
  }

  #view-settings .admin-password-grid {
    gap: 8px;
  }

  #view-settings .user-row {
    padding: 10px;
    gap: 8px;
    overflow: hidden;
  }

  #view-settings .user-row > span {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  #view-settings .user-row .line-actions {
    width: 100%;
  }

  #view-settings .user-row .line-actions button {
    width: 100%;
    flex-basis: 100%;
  }

  .approval-grid > .panel,
  .settings-grid > .panel,
  .admin-editor,
  .admin-editor label {
    min-width: 0;
  }

  .admin-editor select,
  .admin-editor input,
  .admin-editor textarea {
    max-width: 100%;
    min-width: 0;
  }

  .admin-editor .actions {
    gap: 8px;
  }

  .admin-editor .actions button {
    width: 100%;
  }

  .approval-calendar {
    gap: 8px;
  }

  .calendar-days {
    gap: 8px;
    overflow-x: hidden;
    padding-bottom: 2px;
  }

  .approval-calendar button:not(.calendar-nav) {
    flex-basis: calc((100% - 32px) / 5);
    min-width: 0;
    min-height: 62px;
    padding: 8px 6px;
  }

  .approval-calendar button strong {
    font-size: 0.92rem;
  }

  .approval-calendar button small,
  .approval-calendar button span {
    font-size: 0.64rem;
  }

  .worker-identity strong {
    font-size: 1.55rem;
  }

  .worker-identity span {
    font-size: 0.95rem;
    line-height: 1.25;
    overflow-wrap: anywhere;
  }

  .helper-box {
    padding: 10px 12px;
  }

  .date-flags {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .check-row {
    min-height: 46px;
    padding: 0 10px;
  }

  .check-row input {
    width: 24px;
    height: 24px;
    min-height: 24px;
  }

  .task-browser {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .task-menu-panel {
    height: auto;
    max-height: 220px;
    padding: 10px;
    border-radius: 8px;
  }

  .task-type-menu,
  .task-menu {
    gap: 7px;
  }

  .task-menu button {
    min-height: 42px;
    padding: 8px 10px;
    line-height: 1.18;
  }

  .task-search-panel {
    min-height: 0;
    grid-template-rows: auto auto auto;
  }

  .compact-search {
    max-width: none;
  }

  .task-results {
    height: auto;
    max-height: 360px;
    overflow: auto;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: inset 0 0 0 1px rgba(216, 222, 231, 0.45);
  }

  .task-result {
    min-height: 58px;
    padding: 10px;
    align-items: center;
  }

  .task-result span,
  .task-result strong {
    min-width: 0;
  }

  .task-result span span {
    display: block;
    line-height: 1.25;
  }

  .task-lines {
    gap: 8px;
  }

  .line-row {
    grid-template-columns: minmax(0, 1fr) 104px 38px;
    grid-template-areas:
      "project project remove"
      "task hours remove";
    gap: 8px;
    align-items: center;
    padding: 10px;
  }

  .line-row > div:first-child {
    grid-area: project;
  }

  .line-row > div:nth-child(2) {
    grid-area: task;
  }

  .line-row label {
    grid-area: hours;
  }

  .line-row .icon-button {
    grid-area: remove;
    align-self: stretch;
    height: auto;
  }

  .line-row strong {
    line-height: 1.18;
  }

  .line-row span {
    line-height: 1.2;
  }

  .line-row label {
    font-size: 0.78rem;
  }

  .line-row select {
    min-height: 40px;
    padding: 8px;
  }

  .totals-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .totals-grid > div {
    padding: 12px;
  }

  .totals-grid strong {
    font-size: 1.4rem;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .guide-layout {
    gap: 10px;
  }

  .guide-card {
    gap: 10px;
  }

  .guide-card h2 {
    font-size: 1.12rem;
  }

  .guide-steps,
  .guide-tips {
    gap: 8px;
    padding-left: 18px;
  }

  .status-guide {
    gap: 8px;
  }

  .status-guide div {
    padding: 9px 10px;
  }

  .approval-card,
  .approval-line,
  .user-row {
    grid-template-columns: 1fr;
  }

  .line-actions {
    justify-content: stretch;
  }

  .line-actions button {
    flex: 1 1 auto;
  }

  .excel-table th,
  .excel-table td {
    padding: 8px;
  }
}
