:root {
  --accent: #000000;
  --bg: #F9F9F9;
  --surface: #FFFFFF;
  --border: #E5E5E5;
  --border-strong: #C4C4C4;
  --text-primary: #0A0A0A;
  --text-secondary: #6B7280;
  --text-placeholder: #9CA3AF;
  --text-on-accent: #FFFFFF;
  --success-bg: #DCFCE7;
  --success-text: #15803D;
  --neutral-bg: #F3F4F6;
  --neutral-text: #4B5563;
  --error-bg: #FEE2E2;
  --error-text: #DC2626;
  --info-bg: #DBEAFE;
  --info-text: #1D4ED8;
  --radius: 6px;
  --radius-pill: 999px;
  --sidebar-w: 200px;
  --font: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: var(--font); }

.gnb {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 100;
}
.gnb__logo {
  font-size: 16px; font-weight: 800; letter-spacing: -0.01em;
  color: var(--accent); padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}
.gnb__menu { display: flex; flex-direction: column; flex: 1; padding: 12px 0; }
.gnb__item {
  padding: 10px 20px; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); position: relative;
}
.gnb__item:hover { color: var(--text-primary); background: var(--bg); }
.gnb__item--active { color: var(--text-primary); font-weight: 600; background: var(--bg); }
.gnb__item--active::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 3px;
  background: var(--accent); border-radius: 0 2px 2px 0;
}
.gnb__logout {
  margin-top: auto; font-size: 12px; color: var(--text-secondary);
  padding: 14px 20px; border-top: 1px solid var(--border); font-weight: 500;
}
.gnb__logout:hover { color: var(--text-primary); background: var(--bg); }

.page { padding: 44px 0 80px var(--sidebar-w); }
.container { max-width: 1560px; margin: 0 auto; padding: 0 40px; }
.page-header { margin-bottom: 36px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.page-header__right { display: flex; gap: 10px; flex-shrink: 0; padding-top: 6px; align-items: center; flex-wrap: wrap; }
.page-title { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.2; }
.page-subtitle { font-size: 14px; color: var(--text-secondary); margin-top: 6px; }

.section { margin-bottom: 28px; }
.section__body { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.section--cards { display: flex; gap: 16px; flex-wrap: wrap; }
.section--filter { display: flex; gap: 20px; align-items: flex-end; flex-wrap: wrap; }
.section--filter .field-wrap { margin-bottom: 0; flex: 1; min-width: 180px; max-width: 320px; }

.field-wrap { margin-bottom: 20px; }
.field-wrap:last-child { margin-bottom: 0; }
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.req { color: #ef4444; margin-left: 2px; }
.field-input, .field-select, .field-textarea {
  width: 100%; padding: 9px 13px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; color: var(--text-primary); background: var(--surface); outline: none;
}
.field-input:focus, .field-select:focus, .field-textarea:focus {
  border-color: var(--text-primary); box-shadow: 0 0 0 3px #0000000f;
}
.field-input::placeholder, .field-textarea::placeholder { color: var(--text-placeholder); }
.field-hint { font-size: 12px; color: var(--text-secondary); margin-top: 5px; }
.field-hint--top { margin-top: -2px; margin-bottom: 8px; }
.field-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%236B7280' d='M5 7L0 2h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px; cursor: pointer;
}
.field-textarea { resize: vertical; min-height: 100px; }
.field-wrap--inline { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; }
.field-wrap--inline .field-label { margin-bottom: 0; }
.field-error { font-size: 12px; color: var(--error-text); margin-top: 6px; }

.toggle { cursor: pointer; display: inline-flex; align-items: center; }
.toggle input { display: none; }
.toggle-track { width: 40px; height: 22px; border-radius: 11px; background: var(--border); position: relative; transition: background .2s; }
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle-thumb { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 1px 3px #0003; }
.toggle input:checked + .toggle-track .toggle-thumb { left: 21px; }

.summary-card {
  flex: 1; min-width: 200px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px 24px;
}
.summary-card__label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 10px; }
.summary-card__value { font-size: 32px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.summary-card__breakdown { font-size: 12px; color: var(--text-secondary); margin-top: 6px; }

.badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap;
}
.badge--active { background: var(--success-bg); color: var(--success-text); }
.badge--closed { background: var(--neutral-bg); color: var(--neutral-text); }
.badge--source { background: transparent; border: 1px solid var(--border-strong); color: var(--text-secondary); font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 12px; padding: 2px 10px; }

.table-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.table-title { font-size: 15px; font-weight: 600; }
.table-toolbar-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead tr { background: #f5f5f5; }
.data-table th {
  text-align: left; padding: 11px 16px; font-size: 11px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--text-secondary);
  white-space: nowrap; border-bottom: 1px solid var(--border);
}
.data-table td { padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--text-secondary); white-space: nowrap; }
.data-table td:first-child { color: var(--text-primary); font-weight: 500; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafafa; }
.data-table tbody tr.clickable { cursor: pointer; }
.table-empty { padding: 32px 16px; text-align: center; color: var(--text-secondary); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.btn-export, .btn-secondary {
  font-size: 13px; padding: 7px 14px; border: 1px solid var(--border-strong);
  border-radius: var(--radius); background: var(--surface); color: var(--text-secondary);
  cursor: pointer; font-weight: 500;
}
.btn-export:hover, .btn-secondary:hover { border-color: var(--text-primary); color: var(--text-primary); }
.btn-new, .btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 7px 16px; background: var(--accent); color: var(--text-on-accent);
  border: none; border-radius: var(--radius); font-weight: 600; cursor: pointer;
}
.btn-primary { padding: 10px 24px; font-size: 14px; }
.btn-new:hover, .btn-primary:hover { opacity: .85; }
.btn-ghost {
  padding: 6px 10px; font-size: 12px; border: 1px solid var(--border-strong);
  border-radius: 4px; background: var(--surface); cursor: pointer;
}
.btn-ghost:hover { border-color: var(--text-primary); }

.header-filter { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.header-filter__label { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.header-filter__select { width: auto !important; padding: 7px 32px 7px 12px !important; font-size: 13px !important; min-width: 130px; }
.header-filter__date { width: 138px !important; padding: 7px 10px !important; font-size: 13px !important; }
.header-filter__dash { color: var(--text-secondary); }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 52px 40px 44px; }
.login-logo { font-size: 26px; font-weight: 800; letter-spacing: -0.01em; text-align: center; margin-bottom: 6px; }
.login-subtitle { font-size: 13px; color: var(--text-secondary); text-align: center; margin-bottom: 36px; }
.login-submit { width: 100%; margin-top: 20px; padding: 12px; font-size: 15px; }
.form-error {
  background: var(--error-bg); color: var(--error-text); border-radius: var(--radius);
  padding: 10px 12px; font-size: 13px; margin-bottom: 18px;
}
.flash {
  border-radius: var(--radius); padding: 10px 14px; font-size: 13px; margin-bottom: 18px;
}
.flash--ok { background: var(--success-bg); color: var(--success-text); }
.flash--error { background: var(--error-bg); color: var(--error-text); }
.btn-danger {
  padding: 6px 10px; font-size: 12px; border: 1px solid #fecaca;
  border-radius: 4px; background: var(--surface); color: var(--error-text); cursor: pointer;
}
.btn-danger:hover { background: var(--error-bg); border-color: var(--error-text); }
.inline-add {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 16px; padding-top: 16px;
  border-top: 1px dashed var(--border);
}
.inline-add .field-input { width: 220px; }
.inline-add .btn-secondary { white-space: nowrap; }

.cd-info-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; margin-bottom: 24px; }
.cd-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px 48px; }
.cd-info-full { grid-column: 1 / -1; }
.cd-info-label { font-size: 11px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.cd-info-value { font-size: 14px; line-height: 1.6; word-break: break-all; }
.cd-link { color: var(--accent); text-decoration: underline; }
.cd-memo { color: var(--text-secondary); }
.cd-stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 32px; }
.cd-stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px 28px; }
.cd-stat-label { font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 12px; }
.cd-stat-value { font-size: 36px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.cd-stat-breakdown { font-size: 12px; color: var(--text-secondary); margin-top: 8px; }
.cd-table-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.cd-table-title { font-size: 20px; font-weight: 700; }
.cd-filter-inline { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }
.cd-filter-input { width: 120px !important; }

.md-layout { display: flex; gap: 24px; align-items: flex-start; }
.md-sidebar { width: 280px; flex-shrink: 0; display: flex; flex-direction: column; gap: 16px; }
.md-main { flex: 1; min-width: 0; }
.md-profile-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px 20px 24px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
}
.profile-avatar {
  width: 64px; height: 64px; border-radius: 50%; background: var(--bg); border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; color: var(--text-secondary);
}
.profile-name { font-size: 16px; font-weight: 700; }
.profile-id { font-size: 12px; color: var(--text-secondary); }
.display-grid { display: grid; grid-template-columns: 110px 1fr; }
.display-key { font-size: 12px; font-weight: 600; color: var(--text-secondary); padding: 11px 0; border-bottom: 1px solid var(--border); }
.display-val { font-size: 14px; padding: 11px 0 11px 12px; border-bottom: 1px solid var(--border); word-break: break-word; }
.display-grid > :nth-last-child(-n+2) { border-bottom: none; }

.repeater { display: flex; flex-direction: column; gap: 10px; }
.repeater-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: start; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff; padding: 10px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; z-index: 200;
}

@media (max-width: 960px) {
  .gnb { width: 100%; height: auto; bottom: auto; flex-direction: row; align-items: center; }
  .gnb__logo { border-bottom: none; padding: 14px 16px; }
  .gnb__menu { flex-direction: row; padding: 0; }
  .gnb__item--active::before { display: none; }
  .gnb__logout { margin-top: 0; border-top: none; }
  .page { padding: 88px 0 40px; }
  .container { padding: 0 16px; }
  .cd-info-grid, .cd-stats-row { grid-template-columns: 1fr; }
  .md-layout { flex-direction: column; }
  .md-sidebar { width: 100%; }
  .repeater-row { grid-template-columns: 1fr; }
}
