:root {
  --bg: #fff8e6;
  --card: #ffffff;
  --ink: #1e2a45;
  --sub: #5d6b85;
  --line: #f2e3ae;
  --primary: #ffc800;
  --primary-dark: #8a5c00;
  --primary-soft: #fff3c4;
  --accent: #ffe066;
  --accent-dark: #a67c00;
  --accent-soft: #fff6d6;
  --green: #189a6d;
  --green-soft: #e2f6ec;
  --amber: #c25a12;
  --amber-soft: #ffe4cf;
  --red: #e0526a;
  --red-soft: #fdeaee;
  --violet: #8b6bf0;
  --violet-soft: #ece6fd;
  --radius: 18px;
  --radius-sm: 12px;
  --border-w: 2.5px;
  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --shadow-lg: 6px 6px 0 var(--ink);
  --grad-primary: linear-gradient(135deg, #ffd633, #ffa500);
  --font-display: "Black Han Sans", "Pretendard", "Apple SD Gothic Neo", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(700px 380px at 10% -10%, #ffedb0 0%, transparent 60%),
    radial-gradient(620px 340px at 105% 0%, #ffd7b0 0%, transparent 55%),
    radial-gradient(520px 280px at 50% 115%, #e3ddfb 0%, transparent 55%),
    var(--bg);
  background-repeat: no-repeat;
  color: var(--ink);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.wrap {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

.wrap.narrow { max-width: 520px; }
.wrap.home { max-width: 600px; }

.home-hero { text-align: center; margin-top: 48px; margin-bottom: 22px; }
.home-hero-icon {
  font-size: 64px;
  display: inline-block;
  margin-bottom: 10px;
  filter: drop-shadow(3px 3px 0 var(--ink));
}
.home-title { font-size: 44px; margin: 0 0 8px; letter-spacing: -.5px; }
.home-tagline { color: var(--sub); font-size: 15.5px; font-weight: 600; margin: 0; }

.home-role-tabbar {
  margin: 0 auto 20px;
  width: 100%;
  justify-content: center;
  padding: 6px;
}
.home-role-tabbar button {
  flex: 1;
  padding: 14px 10px;
  font-size: 16px;
  white-space: nowrap;
}

.home-card { padding: 28px; }
.home-card h2 { font-size: 22px; margin-bottom: 6px; }

/* Top nav */
.topnav {
  background: var(--card);
  border-bottom: var(--border-w) solid var(--ink);
  border-radius: 0 0 16px 16px;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow);
}
.topnav-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.nav-home-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--primary);
  border: var(--border-w) solid var(--ink);
  font-size: 21px;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform .08s ease, box-shadow .08s ease;
  flex-shrink: 0;
}
.nav-home-btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.nav-home-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

.brand {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 22px;
  white-space: nowrap;
}
.brand small {
  display: block;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--sub);
}
.tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-left: auto;
}
.tabs a {
  text-decoration: none;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--sub);
  white-space: nowrap;
  border: var(--border-w) solid transparent;
}
.tabs a:hover {
  background: var(--primary-soft);
  color: var(--primary-dark);
}
.tabs a.active {
  background: var(--primary);
  color: var(--ink);
  border-color: var(--ink);
}
.logout-btn {
  border: none;
  background: none;
  color: var(--sub);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  padding: 8px 8px;
}

h1 { font-family: var(--font-display); font-weight: 400; font-size: 29px; margin: 28px 0 4px; letter-spacing: -.2px; }
h2 { font-family: var(--font-display); font-weight: 400; font-size: 19px; margin: 0 0 12px; letter-spacing: -.2px; }
.page-sub { color: var(--sub); font-size: 13.5px; margin: 0 0 24px; }

.card {
  background: var(--card);
  border: var(--border-w) solid var(--ink);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-lg);
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--ink);
}
.field .hint { font-size: 12px; color: var(--sub); margin-top: 4px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], select, textarea {
  width: 100%;
  padding: 11px 14px;
  border: var(--border-w) solid var(--ink);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
  transition: box-shadow .1s ease, transform .1s ease;
}
textarea { resize: vertical; min-height: 72px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
  transform: translate(-1px, -1px);
}

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: var(--border-w) solid var(--ink);
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform .07s ease, box-shadow .07s ease;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 0px 0px 0 var(--ink); }
.btn-primary { background: var(--primary); color: var(--ink); }
.btn-primary:hover { background: #ffd633; }
.btn-secondary { background: var(--accent); color: var(--ink); }
.btn-secondary:hover { background: #ffe985; }
.btn-ghost { background: #fff; color: var(--ink); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #e86b80; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 13px; box-shadow: 2px 2px 0 var(--ink); }
.btn-sm:hover { box-shadow: 3px 3px 0 var(--ink); }
.btn-sm:active { box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: var(--shadow-sm); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  border: 1.5px solid currentColor;
}
.badge-wait { background: var(--amber-soft); color: var(--amber); }
.badge-done { background: var(--green-soft); color: var(--green); }
.badge-checked { background: var(--violet-soft); color: var(--violet); }
.badge-rejected { background: var(--red-soft); color: var(--red); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--sub); font-weight: 700; font-size: 12.5px; }
tr:last-child td { border-bottom: none; }

.empty {
  text-align: center;
  color: var(--sub);
  padding: 40px 20px;
  font-size: 14px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  border: var(--border-w) solid var(--ink);
  font-size: 13.5px;
  font-weight: 700;
  box-shadow: 4px 4px 0 rgba(30,42,69,.35);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }
.toast.error { background: var(--red); border-color: var(--ink); }

.class-list { display: grid; gap: 10px; }
.class-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border: var(--border-w) solid var(--ink);
  border-radius: var(--radius-sm);
  background: #fff;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .1s, transform .1s;
}
.class-item:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.class-item .name { font-weight: 800; font-size: 15px; }
.class-item .meta { font-size: 12.5px; color: var(--sub); margin-top: 2px; }
.class-item .arrow { color: var(--sub); }

.home-tile {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: transform .12s ease, border-color .15s ease;
}
.home-tile:hover { transform: translateY(-2px); border-color: var(--primary); }
.home-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  border: var(--border-w) solid var(--ink);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 28px;
  margin-bottom: 12px;
  box-shadow: 3px 3px 0 var(--ink);
}
.home-icon.mint { background: var(--primary-soft); }
.home-icon.yellow { background: var(--accent-soft); }

.title-gradient {
  font-family: var(--font-display);
  font-weight: 400;
  background: linear-gradient(90deg, var(--accent-dark), var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.doctype-picker { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.doctype-option {
  flex: 1;
  min-width: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 10px;
  border: var(--border-w) solid var(--ink);
  border-radius: var(--radius-sm);
  background: #fff;
  font-weight: 800;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .08s ease, box-shadow .08s ease, background .1s ease;
}
.doctype-option:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.doctype-option .doctype-icon { font-size: 26px; }
.doctype-option.active {
  color: var(--ink);
  background: var(--primary);
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.tabbar {
  display: flex;
  gap: 4px;
  background: var(--primary-soft);
  border: var(--border-w) solid var(--ink);
  padding: 4px;
  border-radius: 999px;
  margin-bottom: 18px;
  width: fit-content;
  box-shadow: var(--shadow-sm);
}
.tabbar button {
  border: none;
  background: transparent;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--primary-dark);
  cursor: pointer;
  font-family: inherit;
  transition: background .1s ease;
}
.tabbar button.active { background: var(--ink); color: #fff; }

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.calendar .dow { text-align: center; font-size: 12px; font-weight: 700; color: var(--sub); padding-bottom: 4px; }
.calendar .cell {
  min-height: 64px;
  border: 1.75px solid var(--ink);
  border-radius: 10px;
  padding: 6px;
  cursor: pointer;
  background: #fff;
  position: relative;
  transition: transform .08s ease, box-shadow .08s ease;
}
.calendar .cell.empty-cell { border: none; cursor: default; background: transparent; }
.calendar .cell:hover { transform: translate(-1px, -1px); box-shadow: 2px 2px 0 var(--ink); }
.calendar .cell .date-num { font-size: 12.5px; color: var(--sub); font-weight: 600; }
.calendar .cell.today { background: var(--primary-soft); }
.calendar .cell.today .date-num { color: var(--primary-dark); font-weight: 800; }
.calendar .cell .count {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: var(--red);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  padding: 1px 7px;
  border: 1.5px solid var(--ink);
}
.calendar .cell.selected { background: var(--accent); box-shadow: 2px 2px 0 var(--ink); }

.roster-table-wrap, .list-scroll { overflow-x: auto; }

.doctype-section { display: none; }

.sig-pad-wrap {
  border: var(--border-w) dashed var(--ink);
  border-radius: var(--radius-sm);
  background: #fcfcfd;
  touch-action: none;
}
.sig-pad-wrap canvas { display: block; width: 100%; touch-action: none; }

.template-canvas-wrap {
  position: relative;
  border: var(--border-w) solid var(--ink);
  border-radius: var(--radius-sm);
  overflow: auto;
  background: #eef4f1;
  max-height: 640px;
}
.template-canvas-wrap canvas { display: block; }
.field-marker {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
  cursor: grab;
}
.field-marker.sig-marker { border-radius: 6px; width: auto; height: auto; background: rgba(255,200,0,.2); border: 1.5px dashed var(--accent-dark); transform: none; }
.field-marker .tag {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

.field-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 1.75px solid var(--ink);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 13.5px;
  cursor: pointer;
  background: #fff;
}
.field-list-item.armed { background: var(--accent-soft); box-shadow: 2px 2px 0 var(--ink); }
.field-list-item.placed .dot { background: var(--green); }
.field-list-item .dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--red); flex-shrink: 0;
  border: 1.5px solid var(--ink);
}
.field-list-item .name { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.field-list-item .coord { color: var(--sub); font-size: 11.5px; }

.coord-tune {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  gap: 6px;
  margin-top: 4px;
}
.coord-tune input { padding: 6px 8px; font-size: 12.5px; border-radius: 10px; }

.notice {
  background: var(--accent-soft);
  color: #6b4a0d;
  border: var(--border-w) solid var(--ink);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  margin-bottom: 16px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.notice.info { background: var(--primary-soft); color: var(--primary-dark); }

.loading-block { text-align: center; padding: 60px 20px; color: var(--sub); font-size: 14px; }

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  overflow-y: auto;
}

.modal-content {
  background: var(--card);
  max-width: 500px;
  width: 100%;
  margin-top: 20px;
  max-height: 70vh;
  overflow-y: auto;
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 20px; }
.stat-box { position: relative; overflow: hidden; background: #fff; border: var(--border-w) solid var(--ink); border-radius: var(--radius); padding: 16px; text-align: center; box-shadow: var(--shadow-sm); }
.stat-box::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 6px;
  background: var(--primary);
}
.stat-box:nth-child(2)::before { background: var(--accent); }
.stat-box:nth-child(3)::before { background: var(--violet); }
.stat-box:nth-child(4)::before { background: var(--red); }
.stat-box .num { font-size: 26px; font-weight: 800; }
.stat-box .lbl { font-size: 12.5px; color: var(--sub); margin-top: 2px; font-weight: 600; }

@media (max-width: 560px) {
  .topnav-inner { padding: 12px 16px; }
  .wrap { padding: 0 14px 60px; }
  .card { padding: 16px; }
  h1 { font-size: 20px; }
}
