:root {
  --bg: #eef1f8;
  --card: #ffffff;
  --border: #e4e8f0;
  --text: #171d2b;
  --text-dim: #6b7585;
  --primary: #3758f9;
  --primary-dark: #2743d1;
  --primary-light: #6a86ff;
  --primary-soft: #eef1ff;
  --ok: #14a06b;
  --ok-soft: #e7faf1;
  --bad: #e5484d;
  --bad-soft: #fdeceb;
  --warn: #d98c0e;
  --warn-soft: #fdf3e3;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 1px 2px rgba(20, 24, 40, .04), 0 8px 24px rgba(20, 24, 40, .05);
  --shadow-lift: 0 4px 10px rgba(20, 24, 40, .06), 0 16px 36px rgba(20, 24, 40, .09);
  --ease: cubic-bezier(.2, .7, .3, 1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  background:
    radial-gradient(900px 500px at 100% -10%, #e3e9ff 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.app-header {
  position: relative;
  background: linear-gradient(120deg, var(--primary-dark), var(--primary) 55%, var(--primary-light));
  color: #fff;
  padding: 26px 24px;
  overflow: hidden;
}

.header-mesh {
  position: absolute; inset: 0;
  background:
    radial-gradient(420px 220px at 12% 0%, rgba(255,255,255,.16), transparent 60%),
    radial-gradient(360px 220px at 92% 100%, rgba(255,255,255,.14), transparent 60%);
  pointer-events: none;
}

.header-inner {
  position: relative;
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  backdrop-filter: blur(6px);
}

.app-header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.01em;
}

.app-header .sub {
  font-size: 12.5px;
  opacity: .88;
  margin-top: 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge-domain {
  font-size: 11.5px;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.22);
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: .01em;
}

.logout-btn {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.22);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
  font-size: 15px;
  transition: all .15s var(--ease);
}
.logout-btn:hover { background: rgba(255,255,255,.26); transform: translateY(-1px); }

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px 18px 60px;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  width: fit-content;
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.tab-btn {
  border: 0;
  background: transparent;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s ease;
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(55, 88, 249, .35);
}

.tab-btn:not(.active):hover {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn .25s var(--ease); }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }

.stat-card .icon-badge {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  margin-bottom: 10px;
  background: var(--primary-soft);
}
.stat-card .icon-badge.green { background: var(--ok-soft); }
.stat-card .icon-badge.amber { background: var(--warn-soft); }

.stat-card .label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
}

.stat-card .value {
  font-size: 25px;
  font-weight: 800;
  margin-top: 4px;
  color: var(--text);
  letter-spacing: -.01em;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
  transition: box-shadow .18s var(--ease);
}
.card:hover { box-shadow: var(--shadow-lift); }

.card h2 {
  font-size: 15px;
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -.005em;
}

.card .desc {
  font-size: 12.5px;
  color: var(--text-dim);
  margin: 0 0 16px;
  line-height: 1.5;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  transition: all .15s ease;
  background: #fafbff;
}

.dropzone:hover, .dropzone.drag {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.dropzone.drag { transform: scale(1.01); }
.dropzone:hover .icon { transform: translateY(-2px); }

.dropzone .icon { font-size: 28px; opacity: .6; transition: transform .15s var(--ease); display: inline-block; }
.dropzone .main { font-size: 13.5px; font-weight: 600; margin-top: 8px; }
.dropzone .hint { font-size: 11.5px; color: var(--text-dim); margin-top: 4px; }
.dropzone .filename { font-size: 12.5px; color: var(--primary-dark); font-weight: 600; margin-top: 10px; }

input[type=text], input[type=number], input[type=search], input[type=password] {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  font-size: 13.5px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }

label.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
}

.form-row > * { flex: 1; min-width: 140px; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
}

button.btn {
  border: 0;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s var(--ease), background .15s var(--ease), box-shadow .15s var(--ease);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
button.btn:active { transform: scale(.97); }

.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(55,88,249,.28); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 14px rgba(55,88,249,.38); }
.btn-primary:disabled { background: #b7c0e0; cursor: not-allowed; box-shadow: none; }

.btn-ghost { background: var(--primary-soft); color: var(--primary-dark); }
.btn-ghost:hover { background: #dfe4ff; }

.btn-danger { background: var(--bad-soft); color: var(--bad); }
.btn-danger:hover { background: #fbdada; }

.btn-sm { padding: 6px 12px; font-size: 12px; }

table.data {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  margin-top: 4px;
}

table.data th {
  text-align: left;
  padding: 10px 10px;
  color: var(--text-dim);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

table.data td {
  padding: 11px 10px;
  border-bottom: 1px solid #f0f2f8;
  vertical-align: top;
}

table.data tbody tr { transition: background .12s var(--ease); }
table.data tbody tr:hover { background: var(--primary-soft); }

.chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-bad { background: var(--bad-soft); color: var(--bad); }
.chip-muted { background: #f0f2f8; color: var(--text-dim); }

.empty {
  text-align: center;
  padding: 30px 10px;
  color: var(--text-dim);
  font-size: 13px;
}

.toast-wrap {
  position: fixed;
  top: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
}

.toast {
  background: var(--text);
  color: #fff;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: slideIn .2s ease;
  max-width: 320px;
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--bad); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}

.spinner {
  width: 15px; height: 15px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
.spinner.dark {
  border: 2px solid rgba(55,88,249,.2);
  border-top-color: var(--primary);
}
@keyframes spin { to { transform: rotate(360deg); } }

.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--text-dim);
}

.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.search-bar input { flex: 1; }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

@media (max-width: 640px) {
  .container { padding: 14px 10px 50px; }
  table.data { font-size: 12px; }
  table.data th, table.data td { padding: 8px 6px; }
}

/* ---------------- 회선 상세보기 모달 ---------------- */

.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 20, 40, .45);
  backdrop-filter: blur(2px);
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-overlay.show { display: flex; animation: fadeIn .15s var(--ease); }

.modal-card {
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 70px rgba(10,15,40,.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: cardIn .22s var(--ease);
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h2 { margin: 0; font-size: 15px; }

.modal-close {
  border: 0;
  background: var(--primary-soft);
  color: var(--primary-dark);
  width: 30px; height: 30px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 14px;
  transition: background .15s var(--ease);
}
.modal-close:hover { background: #dfe4ff; }

.modal-body {
  padding: 10px 20px 20px;
  overflow-y: auto;
}

.detail-row {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid #f0f2f8;
  font-size: 13px;
}
.detail-label { color: var(--text-dim); font-weight: 600; }
.detail-value { color: var(--text); word-break: break-all; }
.detail-empty { color: #c3c9d6; }

@media (max-width: 480px) {
  .detail-row { grid-template-columns: 110px 1fr; }
}
