:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --text: #182230;
  --muted: #667085;
  --line: #d9e0e8;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --accent: #2563eb;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(24, 34, 48, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Noto Sans SC", "Noto Sans JP", system-ui, sans-serif;
}

body:not(.is-authenticated) .app-shell {
  display: none;
}

body.is-authenticated .login-screen {
  display: none;
}

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

button {
  cursor: pointer;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(15, 118, 110, 0.16), rgba(37, 99, 235, 0.1)),
    var(--bg);
}

.login-panel {
  width: min(430px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 26px;
  box-shadow: var(--shadow);
}

.login-brand {
  color: var(--text);
  margin-bottom: 18px;
}

.login-brand .brand-subtitle {
  color: var(--muted);
}

.primary-login {
  border: 0;
  border-radius: 8px;
  min-height: 44px;
  background: var(--primary);
  color: white;
  font-weight: 800;
}

.login-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.form-feedback {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--primary-dark);
  font-weight: 700;
}

.form-feedback.error {
  color: var(--danger);
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #16212f;
  color: #f8fafc;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #26a69a;
  font-weight: 800;
  font-size: 24px;
}

.brand-name {
  font-size: 20px;
  font-weight: 800;
}

.brand-subtitle {
  color: #b8c4d2;
  font-size: 13px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  border: 0;
  color: #cbd5e1;
  background: transparent;
  min-height: 46px;
  border-radius: 8px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: #233247;
  color: #ffffff;
}

.nav-icon {
  width: 22px;
  text-align: center;
}

.language-box {
  margin-top: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  background: #25354a;
  border-radius: 8px;
}

.user-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #314358;
  border-radius: 8px;
  color: #dbe7f3;
}

.user-box span {
  display: block;
  color: #9fb0c3;
  font-size: 12px;
  margin-bottom: 4px;
}

.user-box strong {
  display: block;
  word-break: break-word;
}

.logout-btn {
  border: 1px solid #50657d;
  background: transparent;
  color: #ffffff;
  min-height: 34px;
  border-radius: 6px;
  font-weight: 700;
}

.lang-btn {
  border: 0;
  color: #cbd5e1;
  background: transparent;
  min-height: 36px;
  border-radius: 6px;
}

.lang-btn.active {
  background: #ffffff;
  color: #16212f;
  font-weight: 700;
}

.main-content {
  padding: 28px;
  display: grid;
  gap: 18px;
  align-content: start;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-weight: 700;
  font-size: 13px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 32px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 4px;
  font-size: 20px;
}

.clock-panel {
  min-width: 210px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
  text-align: right;
  box-shadow: var(--shadow);
}

.clock-panel span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.clock-panel strong {
  font-size: 26px;
}

.notice-band {
  background: #e8f7f4;
  color: #134e48;
  border: 1px solid #a8ded6;
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.punch-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.8fr);
  gap: 18px;
}

.panel,
.print-sheet {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.panel-heading,
.report-header,
.toolbar,
.sheet-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.panel-heading p,
.report-header p {
  margin: 0;
  color: var(--muted);
}

.status-pill {
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 700;
}

.status-pill.on {
  color: var(--primary-dark);
  background: #d9f4ef;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 26px 0;
}

.mode-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  min-height: 74px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text);
}

.mode-btn.active {
  border-color: var(--primary);
  background: #eefcf9;
  color: var(--primary-dark);
  font-weight: 800;
}

.mode-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #d9e6f2;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.primary-action,
.secondary-action {
  border: 0;
  min-height: 112px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  color: white;
}

.primary-action {
  background: var(--primary);
}

.secondary-action {
  background: #334155;
}

.primary-action span,
.secondary-action span {
  font-size: 13px;
  opacity: 0.8;
}

.primary-action strong,
.secondary-action strong {
  font-size: 20px;
}

.today-summary,
.summary-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.today-summary div,
.metric {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 14px;
}

.today-summary span,
.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 5px;
}

.today-summary strong,
.metric strong {
  font-size: 22px;
}

.stacked-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

label span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

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

input[readonly] {
  background: #f3f6fa;
  color: var(--muted);
}

textarea {
  resize: vertical;
}

.text-action,
.muted-action,
.danger-action,
.import-label {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  min-height: 40px;
  border-radius: 8px;
  padding: 9px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
}

.text-action {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.danger-action {
  border-color: #f1b5b1;
  color: var(--danger);
}

.toolbar {
  margin-bottom: 12px;
}

.filters,
.toolbar-actions,
.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.account-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 18px;
  align-items: end;
}

.account-table-wrap {
  margin-top: 14px;
}

.filters label {
  min-width: 170px;
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  box-shadow: var(--shadow);
}

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

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

th {
  background: var(--surface-2);
  font-size: 13px;
  color: var(--muted);
}

td {
  font-size: 14px;
}

.row-actions {
  display: flex;
  gap: 6px;
}

.mini-btn {
  border: 1px solid var(--line);
  background: white;
  border-radius: 6px;
  min-height: 30px;
  padding: 4px 8px;
  color: var(--text);
}

.summary-cards {
  grid-template-columns: repeat(4, 1fr);
  margin: 14px 0;
}

.print-sheet {
  box-shadow: none;
}

.sheet-profile {
  text-align: right;
  color: var(--muted);
  line-height: 1.7;
}

.report-rows {
  display: grid;
  border: 1px solid var(--line);
  border-bottom: 0;
}

.report-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1fr 1fr 2fr;
}

.report-row > div {
  padding: 9px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  min-height: 38px;
}

.report-row > div:last-child {
  border-right: 0;
}

.report-row.header {
  background: var(--surface-2);
  font-weight: 800;
  color: var(--muted);
  font-size: 13px;
}

.signature-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  margin-top: 26px;
}

.signature-row div {
  min-height: 80px;
  border: 1px solid var(--line);
  padding: 10px;
  color: var(--muted);
}

dialog {
  border: 0;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.25);
  width: min(520px, calc(100vw - 24px));
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.dialog-form {
  display: grid;
  gap: 13px;
}

.time-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.import-label input {
  display: none;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 14px;
    gap: 12px;
  }

  .nav-list {
    grid-template-columns: repeat(5, 1fr);
  }

  .nav-item {
    justify-content: center;
  }

  .language-box {
    margin-top: 0;
  }

  .main-content {
    padding: 18px;
  }

  .topbar,
  .notice-band,
  .panel-heading,
  .report-header,
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .punch-grid,
  .today-summary,
  .summary-cards,
  .action-row,
  .mode-switch,
  .account-form {
    grid-template-columns: 1fr;
  }

  .clock-panel {
    text-align: left;
  }
}

@media print {
  body {
    background: white;
  }

  .sidebar,
  .topbar,
  .notice-band,
  .report-header,
  .summary-cards,
  .toolbar,
  #view-punch,
  #view-records,
  #view-settings {
    display: none !important;
  }

  .app-shell,
  .main-content,
  .view.active {
    display: block;
    padding: 0;
  }

  .print-sheet {
    border: 0;
    padding: 0;
  }
}
