:root {
  --ink: #15171a;
  --soft-ink: #424a53;
  --muted: #6e7781;
  --line: #d9dee5;
  --bg: #f6f7f8;
  --panel: #ffffff;
  --teal: #0d766e;
  --teal-dark: #095e58;
  --coral: #c94f4f;
  --amber: #b46a13;
  --mint: #dff3ef;
  --charcoal: #111820;
  --blue: #2563eb;
  --rose: #b4234c;
  --focus: rgba(37, 99, 235, .24);
  --shadow: 0 18px 54px rgba(17, 24, 32, .1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Arial, "Noto Sans KR", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cbd2da;
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--ink);
  background: #fff;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus,
a:focus {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

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

.app-header {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px clamp(16px, 4vw, 42px);
  color: #fff;
  background: var(--charcoal);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--teal);
  font-weight: 900;
}

.brand strong,
.brand span {
  display: block;
  line-height: 1.2;
}

.brand span {
  margin-top: 2px;
  color: rgba(255, 255, 255, .72);
  font-size: 12px;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 64px;
}

.login-shell {
  width: min(960px, calc(100% - 32px));
  margin: 38px auto 64px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 22px;
  align-items: start;
}

.hero-panel,
.panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero-panel {
  padding: clamp(24px, 4vw, 42px);
}

.hero-panel h1,
.section-title h1,
.section-title h2 {
  margin: 0;
  color: #111820;
  font-size: clamp(30px, 5vw, 52px);
  line-height: 1.1;
  font-weight: 900;
}

.hero-panel p,
.section-title p,
.muted {
  color: var(--soft-ink);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
}

.panel {
  padding: 20px;
}

.panel h2,
.panel h3 {
  margin: 0 0 14px;
  color: #111820;
  line-height: 1.25;
}

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

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

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

label {
  display: block;
  margin-bottom: 6px;
  color: #27313b;
  font-size: 13px;
  font-weight: 900;
}

.btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 900;
  text-align: center;
}

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

.btn.secondary {
  color: #23303a;
  border-color: #cbd3dd;
  background: #fff;
}

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

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

.btn:disabled {
  cursor: not-allowed;
  opacity: .58;
}

.btn.full {
  width: 100%;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 16px;
}

.app-message {
  margin: 14px 0 0;
  border-radius: 10px;
  padding: 12px 13px;
  color: #234;
  background: #eef2f4;
  font-weight: 800;
}

.app-message.info {
  color: #0b5f59;
  background: #e8f7f3;
}

.app-message.warn {
  color: #664204;
  background: #fff3d8;
}

.app-message.error {
  color: #8f1d34;
  background: #ffecef;
}

.app-message.success {
  color: #0b5f59;
  background: #e8f7f3;
}

.notice-box {
  margin: 16px 0 0;
  border: 1px solid #f0d7a1;
  border-left: 5px solid var(--amber);
  border-radius: 10px;
  padding: 13px 14px;
  color: #63420a;
  background: #fff8e8;
  font-weight: 800;
}

.field-help {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.field-help.warn,
.link-box small.warn {
  color: #7a4a06;
}

.link-box small.success {
  color: var(--teal-dark);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.summary-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 15px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(17, 24, 32, .06);
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.summary-card strong {
  display: block;
  margin-top: 4px;
  color: #111820;
  font-size: 28px;
  line-height: 1;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) 390px;
  gap: 18px;
  align-items: start;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(160px, .8fr);
  gap: 8px 10px;
  align-items: end;
  margin: 0 0 14px;
}

.filter-bar label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.record-list {
  display: grid;
  gap: 10px;
}

.record-item {
  width: 100%;
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px;
  text-align: left;
  background: #fff;
  cursor: pointer;
}

.record-item:hover,
.record-item.active {
  border-color: #9bcfc7;
  background: #f2fbf9;
}

.record-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.record-head strong {
  font-size: 16px;
}

.meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.record-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.record-flags span {
  border-radius: 999px;
  padding: 4px 8px;
  color: #51606d;
  background: #eef2f4;
  font-size: 12px;
  font-weight: 900;
}

.chip {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  color: var(--teal-dark);
  background: var(--mint);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.chip.warn {
  color: #704104;
  background: #ffe5bd;
}

.chip.danger {
  color: #8f2830;
  background: #ffd9dc;
}

.detail-section {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  border: 1px solid #e4e9ee;
  border-radius: 10px;
  padding: 12px;
  background: #fbfcfd;
}

.record-detail-content {
  display: grid;
  gap: 12px;
}

.record-edit-form {
  display: grid;
  gap: 12px;
}

.detail-actions {
  margin-top: 0;
}

.print-record-title {
  display: none;
}

.detail-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 8px;
  border-bottom: 1px solid #eef2f5;
  padding-bottom: 7px;
}

.detail-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.detail-row b {
  color: #607080;
  font-size: 12px;
}

.detail-row span {
  font-weight: 800;
  overflow-wrap: anywhere;
}

.check {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
  font-size: 14px;
}

.check input {
  width: 18px;
  min-height: 18px;
  margin: 2px 0 0;
}

.checks {
  display: grid;
  gap: 9px;
}

.signature-box {
  border: 1px solid #bfc6d0;
  border-radius: 8px;
  background: #fff;
}

canvas {
  width: 100%;
  height: 180px;
  display: block;
  touch-action: none;
}

.public-done {
  display: none;
  border: 1px solid #a9d9cf;
  border-left: 5px solid var(--teal);
  border-radius: 10px;
  padding: 16px;
  color: #0b5f59;
  background: #effaf7;
  font-weight: 800;
}

.public-done.show {
  display: block;
}

.public-done h2 {
  margin: 0 0 8px;
  color: #064f49;
}

.public-done p {
  margin: 6px 0;
}

.public-done small {
  display: block;
  margin-top: 10px;
  color: #47635f;
}

.is-submitted {
  opacity: .72;
}

.link-box {
  display: grid;
  gap: 8px;
  border: 1px dashed #a9bab6;
  border-radius: 10px;
  padding: 12px;
  background: #f7fbfa;
}

.copy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.link-box code {
  color: var(--teal-dark);
  overflow-wrap: anywhere;
  font-weight: 900;
}

.empty-state {
  border: 1px dashed #cbd2da;
  border-radius: 10px;
  padding: 18px;
  color: var(--muted);
  background: #f8fafb;
  font-weight: 800;
}

@media (max-width: 980px) {
  .login-shell,
  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .grid,
  .grid-3,
  .summary-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 14px;
  }

  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions,
  .actions {
    width: 100%;
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .app-shell,
  .login-shell {
    width: min(100% - 24px, 1180px);
    margin-top: 18px;
  }

  .panel {
    padding: 16px;
  }

  .detail-row {
    grid-template-columns: 1fr;
  }

  .copy-row,
  .filter-bar {
    grid-template-columns: 1fr;
  }
}

@media print {
  .app-header,
  .section-title,
  .summary-grid,
  .toolbar,
  .actions,
  .shop-panel,
  .record-list-panel,
  .public-form-panel,
  .filter-bar,
  .app-message,
  .notice-box {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .app-shell,
  .login-shell {
    width: 100%;
    margin: 0;
  }

  .dashboard-layout {
    display: block;
  }

  .panel {
    border: 0;
    box-shadow: none;
  }

  .print-record-title {
    display: block;
    margin-bottom: 18px;
  }

  .print-record-title h2 {
    margin: 0 0 6px;
    font-size: 24px;
    font-weight: 900;
  }

  .detail-section {
    break-inside: avoid;
    page-break-inside: avoid;
    border-color: #cfd6dd;
    background: #fff;
  }
}

/* v0.2.2 first-use dashboard refinements */
.simple-notice {
  border-color: #cfe5df;
  border-left-color: var(--teal);
  color: #0a5f58;
  background: #f0faf7;
}

.first-use-panel {
  margin-bottom: 18px;
}

.first-use-head,
.panel-heading,
.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.first-use-head h2,
.panel-heading h2 {
  margin-bottom: 4px;
}

.step-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.step-list li {
  counter-increment: step;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 13px 14px 46px;
  background: #fbfcfd;
}

.step-list li::before {
  content: counter(step);
  position: absolute;
  top: 14px;
  left: 13px;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: var(--teal);
  font-size: 12px;
  font-weight: 900;
}

.step-list strong,
.step-list span {
  display: block;
}

.step-list strong {
  margin-bottom: 4px;
  font-size: 14px;
}

.step-list span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.empty-guide {
  display: grid;
  gap: 10px;
}

.empty-guide strong {
  color: var(--ink);
  font-size: 16px;
}

.empty-guide p {
  margin: 0;
}

@media (max-width: 980px) {
  .step-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .first-use-head,
  .panel-heading,
  .toolbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .step-list {
    grid-template-columns: 1fr;
  }
}

@media print {
  .first-use-panel {
    display: none !important;
  }
}

/* v0.3 session record refinements */
.time-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.history-item {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
  font-size: 13px;
}

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

.history-item b {
  color: var(--teal-dark);
}

.compact {
  margin: 0;
}

@media (max-width: 640px) {
  .time-grid,
  .history-item {
    grid-template-columns: 1fr;
  }
}
