:root {
  --primary: #2f5fd6;
  --primary-dark: #23459e;
  --bg: #f4f6fb;
  --card-bg: #ffffff;
  --border: #c9d0dd;
  --text: #1f2733;
  --text-muted: #47526b;
  --danger: #d64545;
  --success: #1f9d55;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Malgun Gothic", "Segoe UI", -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1180px; margin: 0 auto; padding: 24px 20px 60px; }

/* Top bar */
.topbar { background: #101828; color: #fff; }
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; height: 56px; gap: 28px;
}
.brand { color: #fff; font-weight: 700; font-size: 16px; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 18px; flex: 1; }
.nav a { color: #c7cede; padding: 6px 2px; border-bottom: 2px solid transparent; }
.nav a:hover { color: #fff; text-decoration: none; }
.nav a.active { color: #fff; border-bottom-color: var(--primary); }
.user-box { display: flex; align-items: center; gap: 12px; color: #c7cede; font-size: 13px; }
.user-box small { color: #8790a3; margin-left: 2px; }
.btn-link { color: var(--primary); font-weight: 600; background: none; border: none; cursor: pointer; padding: 0; }
.btn-link:hover { color: var(--primary-dark); text-decoration: underline; }
.topbar .btn-link { color: #c7cede; font-weight: 400; }
.topbar .btn-link:hover { color: #fff; text-decoration: none; }

/* Layout helpers */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.page-title { font-size: 20px; margin: 0 0 16px; display: flex; align-items: center; gap: 10px; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; margin-top: 20px; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.stack-sections { display: flex; flex-direction: column; gap: 20px; margin-top: 20px; }
.stack-sections .inline-form .grow { min-width: 220px; }
.stack-sections table td:nth-child(2), .stack-sections table td:nth-child(3) { min-width: 200px; }

/* Card */
.card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 20px; margin-bottom: 20px;
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-header h2 { font-size: 15px; margin: 0; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 20px; }
@media (max-width: 900px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card {
  display: block; background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; text-align: center; text-decoration: none; cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.stat-card:hover {
  border-color: var(--primary); box-shadow: 0 4px 12px rgba(47, 95, 214, 0.15);
  text-decoration: none; transform: translateY(-1px);
}
.stat-label { color: var(--text-muted); font-size: 13px; margin-bottom: 6px; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--primary-dark); }

/* Table */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; font-size: 13px; }
.table th { color: var(--text-muted); font-weight: 600; background: #fafbfd; }
.table tr.row-link { cursor: pointer; }
.table tr.row-link:hover { background: #f5f8ff; }
.nowrap { white-space: nowrap; }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pre-line { white-space: pre-line; }
.muted { color: var(--text-muted); font-size: 13px; }
.empty { color: var(--text-muted); text-align: center; padding: 30px 0; }

/* Badge */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-cat-가맹점 { background: #e6f0ff; color: #2f5fd6; }
.badge-cat-대리점 { background: #fff1e0; color: #c67200; }
.badge-cat-제휴사 { background: #eafaf0; color: #1f9d55; }
.badge-접수 { background: #eef0f4; color: #5b6472; }
.badge-처리중 { background: #fff1e0; color: #c67200; }
.badge-완료 { background: #eafaf0; color: #1f9d55; }
.badge-expiring { background: #fff1e0; color: #c67200; margin-left: 6px; }
.badge-expired { background: #fdeeee; color: var(--danger); margin-left: 6px; }

/* Notice banner */
.notice-banner { padding: 12px 16px; border-radius: 8px; font-size: 13.5px; margin-bottom: 16px; }
.notice-warning { background: #fff1e0; color: #8a5300; }
.notice-danger { background: #fdeeee; color: #a3282f; }
.alert-card { border-color: #f3d9b1; background: #fffaf2; }

/* Forms */
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-muted); }
input, select, textarea {
  font-family: inherit; font-size: 14px; padding: 9px 10px; border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); background: #fff;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
textarea.autoresize { resize: none; overflow: hidden; line-height: 1.35; min-height: 38px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .span2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span2 { grid-column: span 1; } }

.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-label { flex-direction: row; align-items: center; gap: 8px; }

.inline-form { display: flex; gap: 8px; margin-bottom: 14px; align-items: center; flex-wrap: wrap; }
.stack-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.grow { flex: 1; min-width: 120px; }
.small { padding: 5px 8px; font-size: 12px; }

/* Buttons */
.btn {
  display: inline-block; padding: 9px 16px; border-radius: 6px; font-size: 13px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }
.btn-secondary { background: #fff; border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: #f2f4f8; text-decoration: none; }
.btn-danger { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: #fdeeee; }
.btn-block { width: 100%; }
.btn-group { display: flex; gap: 8px; }
.btn-link-danger { color: var(--danger); }

/* Login */
.login-wrap { display: flex; justify-content: center; padding-top: 60px; }
.login-card { width: 340px; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { font-size: 18px; margin: 0; text-align: center; }
.login-card .sub { color: var(--text-muted); font-size: 13px; text-align: center; margin: -8px 0 4px; }

/* Info grid */
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; }
.info-grid > div { display: flex; gap: 10px; font-size: 14px; }
.info-grid .span2 { grid-column: span 2; }
.info-label { color: var(--text-muted); min-width: 90px; flex-shrink: 0; }
@media (max-width: 700px) { .info-grid { grid-template-columns: 1fr; } .info-grid .span2 { grid-column: span 1; } }

/* Flash */
.flash-wrap { margin-bottom: 16px; }
.flash { padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 8px; }
.flash-success { background: #eafaf0; color: #1f9d55; }
.flash-error { background: #fdeeee; color: var(--danger); }

.error-card { text-align: center; padding: 60px 20px; }
.error-card h1 { font-size: 48px; margin: 0 0 10px; color: var(--primary-dark); }

/* Mobile nav */
.nav-toggle {
  display: none; background: none; border: none; color: #fff; font-size: 20px;
  cursor: pointer; padding: 4px 8px; margin-left: auto;
}
.user-box-mobile { display: none; }

@media (max-width: 760px) {
  .topbar-inner { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 0; }
  .brand { font-size: 14px; flex: 1; }
  .nav-toggle { display: block; }
  .user-box-desktop { display: none; }
  .nav {
    display: none; flex-direction: column; align-items: stretch; width: 100%;
    gap: 0; margin-top: 10px; border-top: 1px solid #2a3350;
  }
  .nav.nav-open { display: flex; }
  .nav a { padding: 12px 4px; border-bottom: 1px solid #2a3350; }
  .nav a.active { border-bottom-color: var(--primary); }
  .user-box-mobile {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 4px 4px; font-size: 13px;
  }

  .container { padding: 16px 14px 40px; }
  .page-header { flex-direction: column; align-items: stretch; gap: 10px; }
  .page-title { font-size: 18px; flex-wrap: wrap; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card { padding: 14px; }
  .btn-group { flex-wrap: wrap; }
  .btn-group form { flex: 1; }
  .btn-group .btn, .btn-group form .btn { width: 100%; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar select, .filter-bar input, .filter-bar button { width: 100%; }
  .card > .inline-form, .stack-form > .inline-form { flex-direction: column; align-items: stretch; }
  .card > .inline-form input, .card > .inline-form select, .card > .inline-form button,
  .stack-form > .inline-form input, .stack-form > .inline-form select, .stack-form > .inline-form button { width: 100%; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; text-align: center; }
}
