:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #d9e0e7;
  --text: #1d2733;
  --muted: #657386;
  --accent: #156f72;
  --accent-dark: #0c5558;
  --warn: #b65d12;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Yu Gothic UI", Meiryo, sans-serif;
  font-size: 14px;
  overflow: hidden;
}

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  min-height: 34px;
  padding: 0 12px;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  background: #9aa8b6;
  cursor: not-allowed;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  min-height: 32px;
  padding: 6px 8px;
}

label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 38px rgba(31, 42, 55, 0.12);
}

.login-panel h1 {
  margin: 0 0 8px;
  font-size: 26px;
}

.error-text {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
}

.app-shell {
  min-height: 100vh;
}

.app-view {
  display: grid;
  gap: 8px;
  height: 100vh;
  padding: 8px 12px;
  grid-template-rows: auto auto auto minmax(0, 1fr);
}

.topbar,
.toolbar,
.workspace,
.metrics {
  width: min(1640px, 100%);
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 4px 0 0;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
}

.topbar p {
  margin: 3px 0 0;
  color: var(--muted);
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

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

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 2px;
  font-size: 20px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 170px 150px 105px 130px;
  gap: 8px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.check-label input {
  width: auto;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 10px;
  align-items: stretch;
  min-height: 0;
}

.table-wrap,
.detail-panel,
.notification-log {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.table-wrap {
  overflow: auto;
  max-height: none;
  min-height: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1040px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #eaf0f4;
  color: #405164;
  font-size: 12px;
  z-index: 1;
}

tr {
  cursor: pointer;
}

tr:hover {
  background: #f7fbfb;
}

tr.selected {
  background: #e2f1f1;
}

tr.deleted-row {
  color: #6c7784;
  background: #f5f6f7;
}

tr.deleted-row strong {
  text-decoration: line-through;
}

tr.due td:first-child {
  border-left: 4px solid var(--warn);
}

td small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.35;
  max-width: 420px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  background: #e9eff5;
  color: #324255;
  font-size: 12px;
  font-weight: 700;
}

.deleted-pill {
  background: #edf0f2;
  color: #69727c;
}

.detail-panel {
  display: grid;
  grid-template-rows: auto minmax(90px, 1fr);
  gap: 8px;
  min-height: 0;
  max-height: 100%;
  padding: 10px;
  position: sticky;
  top: 8px;
}

.detail-panel form {
  display: grid;
  gap: 7px;
  min-height: 0;
}

.detail-head h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
}

.detail-head p {
  margin: 3px 0 0;
  color: var(--muted);
  line-height: 1.25;
  font-size: 12px;
}

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

.save-row {
  display: grid;
  grid-template-columns: 70px 112px 64px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.save-row-top {
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
}

#saveMessage {
  margin: 0;
  min-height: 18px;
  color: var(--accent-dark);
  font-size: 12px;
}

.danger-button {
  background: #b42318;
}

.danger-button:hover {
  background: #8f1d14;
}

.danger-button:disabled {
  background: #c5ccd3;
}

.restore-button {
  background: #20744a;
}

.restore-button:hover {
  background: #175b39;
}

.restore-button:disabled {
  background: #c5ccd3;
}

.notification-log {
  overflow: auto;
  min-height: 0;
  padding: 8px 10px;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.notification-log h2 {
  margin: 0 0 4px;
  font-size: 14px;
}

.notification-log article {
  display: grid;
  gap: 2px;
  padding: 5px 0;
  border-top: 1px solid var(--line);
}

.notification-log article span,
.notification-log p {
  color: var(--muted);
  font-size: 12px;
}

textarea {
  resize: vertical;
  max-height: 70px;
}

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

  .detail-panel {
    position: static;
  }
}

@media (max-width: 780px) {
  .app-view {
    padding: 10px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions button {
    flex: 1 1 140px;
  }

  .metrics,
  .toolbar,
  .grid-two {
    grid-template-columns: 1fr;
  }
}
