:root {
  --ink: #15242a;
  --muted: #61727a;
  --subtle: #8b989e;
  --page: #f2f6f7;
  --surface: #ffffff;
  --surface-soft: #f7f9fa;
  --line: #d7e0e3;
  --line-strong: #bdcbd0;
  --primary: #176b7f;
  --primary-dark: #173f4b;
  --primary-soft: #e8f4f6;
  --green: #138a63;
  --green-soft: #e8f7f1;
  --amber: #b96b09;
  --amber-soft: #fff4e2;
  --red: #c43e45;
  --red-soft: #fdeced;
  --violet: #7155a8;
  --violet-soft: #f1edfa;
  --radius: 8px;
  --shadow: 0 12px 28px rgba(22, 49, 59, 0.12);
  --header-height: 78px;
  --tab-height: 70px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  min-height: 100%;
  background: var(--page);
}

body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button {
  border: 0;
}

button:not(:disabled) {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

svg {
  width: 1em;
  height: 1em;
  stroke-width: 1.9;
}

[hidden] {
  display: none !important;
}

.login-view {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  padding: 28px 18px;
  background: #edf3f4;
}

.login-panel {
  width: min(100%, 390px);
  padding: 30px 28px;
  border: 1px solid var(--line);
  border-top: 5px solid var(--primary);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-mark {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  margin-bottom: 22px;
  border-radius: 7px;
  color: #fff;
  background: var(--primary-dark);
  font-size: 19px;
  font-weight: 800;
}

.login-heading p,
.login-heading h1,
.login-heading span {
  margin: 0;
}

.login-heading p {
  color: var(--primary);
  font-size: 13px;
  font-weight: 650;
}

.login-heading h1 {
  margin-top: 6px;
  font-size: 24px;
  line-height: 1.3;
}

.login-heading span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.login-form {
  display: grid;
  gap: 15px;
  margin-top: 26px;
}

.form-error {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--red);
  font-size: 13px;
  text-align: center;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(var(--tab-height) + env(safe-area-inset-bottom));
}

.app-header {
  position: sticky;
  z-index: 40;
  top: 0;
  display: grid;
  min-height: var(--header-height);
  grid-template-columns: 82px minmax(0, 1fr) 82px;
  align-items: center;
  padding: 10px max(14px, env(safe-area-inset-left));
  color: #fff;
  background: var(--primary-dark);
}

.app-header > #backBtn {
  grid-column: 1;
  justify-self: start;
}

.header-title {
  grid-column: 2;
  min-width: 0;
  text-align: center;
}

.header-title span,
.header-title h1 {
  margin: 0;
}

.header-title span {
  color: #b9d3d9;
  font-size: 11px;
}

.header-title h1 {
  margin-top: 3px;
  overflow: hidden;
  font-size: 20px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  grid-column: 3;
  justify-self: end;
  gap: 2px;
}

.icon-btn {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  padding: 0;
  border-radius: 6px;
  color: inherit;
  background: transparent;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  outline: 2px solid rgba(255, 255, 255, 0.35);
  outline-offset: -2px;
}

.icon-btn svg {
  font-size: 22px;
}

.badge-anchor {
  position: relative;
}

.notification-badge {
  position: absolute;
  top: 5px;
  right: 4px;
  display: grid;
  min-width: 17px;
  height: 17px;
  place-items: center;
  padding: 0 4px;
  border: 2px solid var(--primary-dark);
  border-radius: 9px;
  color: #fff;
  background: var(--red);
  font-size: 9px;
  font-weight: 800;
}

.screen {
  width: min(100%, 1120px);
  min-height: calc(100vh - var(--header-height) - var(--tab-height));
  margin: 0 auto;
  padding: 18px 16px 32px;
  outline: none;
}

.page-intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 15px;
}

.page-intro h2,
.page-intro p {
  margin: 0;
}

.page-intro h2 {
  font-size: 22px;
  line-height: 1.3;
}

.page-intro p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.date-chip,
.status-badge,
.priority-badge,
.count-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.date-chip {
  padding: 8px 11px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.metric {
  min-width: 0;
  min-height: 118px;
  padding: 15px 13px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  color: inherit;
  background: var(--surface);
  text-align: left;
}

.metric.green { border-left-color: var(--green); }
.metric.amber { border-left-color: var(--amber); }
.metric.red { border-left-color: var(--red); }
.metric.violet { border-left-color: var(--violet); }

.metric:hover,
.metric:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 6px 18px rgba(23, 107, 127, 0.12);
  outline: none;
}

.metric-label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.metric-label svg {
  flex: 0 0 auto;
  font-size: 17px;
}

.metric-value {
  display: block;
  margin-top: 10px;
  color: var(--primary);
  font-size: 27px;
  font-weight: 800;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.metric.green .metric-value { color: var(--green); }
.metric.amber .metric-value { color: var(--amber); }
.metric.red .metric-value { color: var(--red); }
.metric.violet .metric-value { color: var(--violet); }

.metric-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}

.metric-note svg {
  flex: 0 0 auto;
  font-size: 14px;
}

.section {
  margin-bottom: 15px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-heading h2,
.section-heading h3,
.section-heading p {
  margin: 0;
}

.section-heading h2 {
  font-size: 18px;
}

.section-heading h3 {
  font-size: 16px;
}

.section-heading p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.section-heading > strong {
  color: var(--primary);
  font-size: 18px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 14px;
}

.toolbar .search-field {
  flex: 1;
}

.search-field {
  position: relative;
  min-width: 0;
}

.search-field svg {
  position: absolute;
  top: 50%;
  left: 12px;
  color: var(--subtle);
  font-size: 17px;
  transform: translateY(-50%);
}

.search-field input {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px 9px 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  outline: none;
}

.search-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.primary-btn,
.secondary-btn,
.danger-btn,
.success-btn,
.text-btn,
.compact-btn {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 7px;
  font-weight: 700;
  line-height: 1.2;
}

.primary-btn,
.secondary-btn,
.danger-btn,
.success-btn {
  padding: 10px 15px;
}

.primary-btn {
  color: #fff;
  background: var(--primary);
}

.primary-btn:hover,
.primary-btn:focus-visible {
  background: #125c6d;
  outline: 3px solid rgba(23, 107, 127, 0.2);
}

.secondary-btn {
  border: 1px solid var(--line-strong);
  color: var(--ink);
  background: var(--surface-soft);
}

.danger-btn {
  color: var(--red);
  background: var(--red-soft);
}

.success-btn {
  color: var(--green);
  background: var(--green-soft);
}

.text-btn {
  min-height: 30px;
  padding: 4px 2px;
  color: var(--primary);
  background: transparent;
  font-size: 12px;
}

.compact-btn {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  color: var(--primary);
  background: var(--surface);
  font-size: 12px;
}

.full-width {
  width: 100%;
}

.button-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.button-row > * {
  flex: 1;
}

.record-list,
.project-list,
.activity-list,
.notification-list,
.user-list,
.file-list {
  display: grid;
  gap: 10px;
}

.project-card,
.task-card,
.record-card,
.approval-card,
.notification-card,
.user-card,
.file-card {
  width: 100%;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: inherit;
  background: var(--surface);
  text-align: left;
}

.project-card {
  display: grid;
  grid-template-columns: 5px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: stretch;
}

.project-accent {
  border-radius: 3px;
  background: var(--project-color, var(--primary));
}

.project-main,
.record-main {
  min-width: 0;
}

.project-title-row,
.record-title-row,
.approval-title-row,
.user-title-row {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 9px;
}

.project-title-row h3,
.record-title-row h3,
.approval-title-row h3,
.user-title-row h3 {
  min-width: 0;
  margin: 0;
  font-size: 15px;
  line-height: 1.42;
  overflow-wrap: anywhere;
}

.project-meta,
.record-meta,
.approval-meta,
.user-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.project-description,
.record-note,
.approval-description {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.project-arrow {
  display: grid;
  align-items: center;
  color: var(--subtle);
}

.progress-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 4px;
  background: #e7edef;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--project-color, var(--primary));
}

.progress-row strong {
  font-size: 11px;
  text-align: right;
}

.status-badge,
.priority-badge,
.count-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
}

.status-badge {
  color: var(--muted);
  background: #edf1f2;
}

.status-badge.doing,
.status-badge.submitted {
  color: var(--primary);
  background: var(--primary-soft);
}

.status-badge.done,
.status-badge.approved {
  color: var(--green);
  background: var(--green-soft);
}

.status-badge.pending,
.status-badge.warning {
  color: var(--amber);
  background: var(--amber-soft);
}

.status-badge.rejected,
.status-badge.delayed,
.status-badge.danger {
  color: var(--red);
  background: var(--red-soft);
}

.priority-badge.p0 { color: var(--red); background: var(--red-soft); }
.priority-badge.p1 { color: var(--amber); background: var(--amber-soft); }
.priority-badge.p2 { color: var(--primary); background: var(--primary-soft); }

.count-badge {
  color: var(--primary);
  background: var(--primary-soft);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.summary-item {
  min-width: 0;
  padding: 11px;
  border-radius: 7px;
  background: var(--surface-soft);
}

.summary-item span,
.summary-item strong {
  display: block;
}

.summary-item span {
  color: var(--muted);
  font-size: 11px;
}

.summary-item strong {
  margin-top: 4px;
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.segmented-tabs,
.filter-tabs {
  display: flex;
  gap: 7px;
  margin-bottom: 14px;
  overflow-x: auto;
  scrollbar-width: none;
}

.segmented-tabs::-webkit-scrollbar,
.filter-tabs::-webkit-scrollbar {
  display: none;
}

.segmented-tabs button,
.filter-tabs button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
  white-space: nowrap;
}

.segmented-tabs button.active,
.filter-tabs button.active {
  border-color: var(--primary);
  color: #fff;
  background: var(--primary);
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.template-button {
  display: grid;
  min-width: 0;
  min-height: 104px;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: inherit;
  background: var(--surface);
  text-align: left;
}

.template-button.active {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
  background: var(--primary-soft);
}

.template-icon {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  color: var(--primary);
}

.template-icon svg {
  font-size: 22px;
}

.template-copy {
  min-width: 0;
}

.template-copy strong,
.template-copy span {
  display: block;
  overflow-wrap: anywhere;
}

.template-copy strong {
  font-size: 13px;
  line-height: 1.35;
}

.template-copy span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 12px;
}

.field {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

.field > span {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  outline: none;
}

.field textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.55;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.field small {
  color: var(--muted);
  font-size: 10px;
}

.param-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  grid-column: 1 / -1;
}

.input-unit {
  position: relative;
}

.input-unit input {
  padding-right: 54px;
}

.input-unit span {
  position: absolute;
  top: 50%;
  right: 10px;
  max-width: 48px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  transform: translateY(-50%);
  white-space: nowrap;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.data-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  font-size: 12px;
}

.data-table th,
.data-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.data-table th {
  color: var(--muted);
  background: var(--surface-soft);
  font-weight: 700;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table .numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.mill-group-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.mill-group-button {
  min-width: 0;
  min-height: 96px;
  padding: 11px 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  text-align: center;
}

.mill-group-button.active {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
  background: var(--primary-soft);
}

.mill-group-id {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  margin: 0 auto 6px;
  border-radius: 50%;
  color: #fff;
  background: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
}

.mill-group-button strong,
.mill-group-button span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mill-group-button strong {
  font-size: 11px;
  line-height: 1.35;
}

.mill-group-button span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.chart-panel {
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
}

.chart-panel h3 {
  margin: 0 0 10px;
  font-size: 13px;
}

.bar-chart {
  display: flex;
  min-height: 160px;
  align-items: end;
  gap: 6px;
}

.bar-item {
  display: grid;
  min-width: 0;
  flex: 1;
  grid-template-rows: 21px 112px 18px;
  align-items: end;
  text-align: center;
}

.bar-value,
.bar-label {
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-fill-wrap {
  display: flex;
  height: 112px;
  align-items: end;
}

.bar-fill {
  width: 100%;
  min-height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--primary);
}

.bar-fill.green { background: var(--green); }
.bar-fill.amber { background: var(--amber); }
.bar-fill.violet { background: var(--violet); }

.activity-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.activity-item:last-child {
  border-bottom: 0;
}

.activity-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 12px;
  font-weight: 800;
}

.activity-item p,
.activity-item small {
  margin: 0;
}

.activity-item p {
  font-size: 12px;
  line-height: 1.5;
}

.activity-item small {
  display: block;
  margin-top: 3px;
  color: var(--subtle);
  font-size: 10px;
}

.notification-card {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.notification-card.unread {
  border-color: #9bc4ce;
  background: #f5fbfc;
}

.notification-icon {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  color: var(--primary);
  background: var(--primary-soft);
}

.notification-icon.approval { color: var(--amber); background: var(--amber-soft); }
.notification-icon.alert { color: var(--red); background: var(--red-soft); }
.notification-icon.system { color: var(--green); background: var(--green-soft); }

.notification-card p,
.notification-card small {
  margin: 0;
}

.notification-card p {
  font-size: 12px;
  line-height: 1.5;
}

.notification-card small {
  display: block;
  margin-top: 4px;
  color: var(--subtle);
  font-size: 10px;
}

.unread-dot {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--red);
}

.approval-flow {
  display: flex;
  gap: 5px;
  align-items: center;
  margin-top: 11px;
  overflow-x: auto;
  color: var(--subtle);
  font-size: 10px;
  white-space: nowrap;
}

.approval-step.done {
  color: var(--green);
}

.approval-step.current {
  color: var(--primary);
  font-weight: 800;
}

.file-card,
.user-card {
  display: flex;
  align-items: center;
  gap: 11px;
}

.file-icon,
.user-avatar {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 7px;
  color: var(--primary);
  background: var(--primary-soft);
}

.file-main,
.user-main {
  min-width: 0;
  flex: 1;
}

.file-main strong,
.file-main span,
.user-main strong,
.user-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-main strong,
.user-main strong {
  font-size: 12px;
}

.file-main span,
.user-main span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.empty-state,
.loading-state {
  display: grid;
  min-height: 160px;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.empty-state svg,
.loading-state svg {
  font-size: 30px;
}

.empty-state p,
.loading-state p {
  margin: 0;
  font-size: 12px;
}

.loading-state svg {
  animation: spin 1s linear infinite;
}

.note-box {
  padding: 12px;
  border-left: 4px solid var(--amber);
  border-radius: 6px;
  color: #70521f;
  background: var(--amber-soft);
  font-size: 12px;
  line-height: 1.55;
}

.note-box.success {
  border-left-color: var(--green);
  color: #1b694f;
  background: var(--green-soft);
}

.modal-layer {
  position: fixed;
  z-index: 200;
  inset: 0;
  display: grid;
  place-items: end center;
  padding: 50px 0 0;
  background: rgba(10, 27, 34, 0.48);
}

.modal {
  display: grid;
  width: min(100%, 720px);
  max-height: calc(100vh - 50px);
  max-height: calc(100dvh - 50px);
  grid-template-rows: auto minmax(0, 1fr);
  border-radius: 10px 10px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal.wide {
  width: min(100%, 980px);
}

.modal-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 10px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2,
.modal-header p {
  margin: 0;
}

.modal-header h2 {
  font-size: 17px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.modal-header p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.modal-header .icon-btn {
  color: var(--muted);
}

.modal-header .icon-btn:hover,
.modal-header .icon-btn:focus-visible {
  background: var(--surface-soft);
  outline-color: var(--line);
}

.modal-body {
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal-body > .section:last-child {
  margin-bottom: 0;
}

.toast {
  position: fixed;
  z-index: 300;
  bottom: calc(var(--tab-height) + env(safe-area-inset-bottom) + 12px);
  left: 50%;
  max-width: min(90vw, 420px);
  padding: 11px 15px;
  border-radius: 7px;
  color: #fff;
  background: var(--ink);
  box-shadow: var(--shadow);
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
  transform: translateX(-50%);
}

.toast.error {
  background: var(--red);
}

.tabbar {
  position: fixed;
  z-index: 100;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  height: calc(var(--tab-height) + env(safe-area-inset-bottom));
  grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 6px max(4px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(4px, env(safe-area-inset-left));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 -6px 20px rgba(22, 49, 59, 0.05);
}

.tabbar button {
  display: grid;
  min-width: 0;
  grid-template-rows: 26px 18px;
  place-items: center;
  padding: 3px 1px;
  color: var(--muted);
  background: transparent;
  font-size: 10px;
}

.tabbar button svg {
  font-size: 21px;
}

.tabbar button.active {
  color: var(--primary);
  font-weight: 800;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (min-width: 760px) {
  .screen {
    padding: 24px 24px 42px;
  }

  .metrics-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .project-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .template-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .modal-layer {
    place-items: center;
    padding: 28px;
  }

  .modal {
    max-height: calc(100vh - 56px);
    border-radius: 10px;
  }
}

@media (min-width: 1000px) {
  .template-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .chart-grid {
    grid-template-columns: 1fr;
  }

  .chart-panel {
    min-height: 215px;
  }
}

@media (max-width: 440px) {
  .screen {
    padding-right: 12px;
    padding-left: 12px;
  }

  .page-intro h2 {
    font-size: 20px;
  }

  .toolbar {
    align-items: stretch;
  }

  .toolbar .primary-btn span {
    display: none;
  }

  .toolbar .primary-btn {
    width: 42px;
    flex: 0 0 42px;
    padding: 0;
  }

  .form-grid,
  .param-grid {
    grid-template-columns: 1fr;
  }

  .field.full,
  .param-grid {
    grid-column: auto;
  }

  .template-button {
    min-height: 112px;
    grid-template-columns: 1fr;
  }

  .template-icon {
    width: 24px;
    height: 24px;
  }
}

@media (max-width: 350px) {
  .metrics-grid,
  .summary-grid,
  .template-grid,
  .mill-group-grid {
    grid-template-columns: 1fr;
  }

  .project-card {
    grid-template-columns: 4px minmax(0, 1fr);
  }

  .project-arrow {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
