/* ════════════════════════════════════════════════════════════════════════
   Cloud Admin — 공유 디자인 시스템 (design-system.css)
   모든 서비스 페이지(/, /alarm, /inventory, /assessment)가 공통으로 링크한다.
   <link rel="stylesheet" href="/design-system.css">
   문서: shared/DESIGN.md
═══════════════════════════════════════════════════════════════════════════ */

/* ── DESIGN TOKENS ───────────────────────────────────────────────────────── */
:root {
  --primary:       #3182f6;
  --primary-hover: #1b64da;
  --primary-light: #f2f6fc;
  --primary-mid:   #ccdcf5;

  --success:       #22c55e;
  --success-light: #f0fdf4;
  --danger:        #f04452;
  --danger-light:  #fff0f1;
  --warning:       #f59e0b;
  --warning-light: #fffbeb;

  /* 차트/배지 액센트 (인벤토리 등 카테고리 색) */
  --green:  #22c55e;
  --red:    #ef4444;
  --orange: #f59e0b;
  --blue:   #3b82f6;
  --purple: #8b5cf6;
  --teal:   #14b8a6;

  --gray-50:  #f9fafb;
  --gray-100: #f2f4f6;
  --gray-200: #e5e8eb;
  --gray-300: #d1d6db;
  --gray-400: #b0b8c1;
  --gray-500: #8b95a1;
  --gray-600: #6b7684;
  --gray-700: #4e5968;
  --gray-800: #333d4b;
  --gray-900: #191f28;

  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;

  --sh-sm: 0 1px 3px rgba(0, 0, 0, .04), 0 1px 2px rgba(0, 0, 0, .02);
  --sh:    0 2px 8px rgba(0, 0, 0, .06), 0 1px 4px rgba(0, 0, 0, .03);
}

/* ── BASE ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont,
    system-ui, Roboto, 'Helvetica Neue', 'Segoe UI', sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  letter-spacing: -0.02em;
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; font-family: inherit; }
a { color: inherit; }

/* ── HEADER (상단 바) ─────────────────────────────────────────────────────── */
.header {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.header-logo {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 16px;
}
.header-title { font-size: 16px; font-weight: 700; color: var(--gray-900); }
.header-right { display: flex; align-items: center; gap: 12px; }
.user-info, .header-user { font-size: 13px; color: var(--gray-500); }

/* ── SIDEBAR (서비스 페이지 공통 셸) ───────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: 220px; height: 100vh;
  background: #fff;
  border-right: 1px solid var(--gray-200);
  display: flex; flex-direction: column;
  z-index: 101; transition: transform .2s;
}
.sidebar-brand {
  padding: 12px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; gap: 10px;
  height: 56px; flex-shrink: 0;
}
.sidebar-brand-icon {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 16px;
}
.sidebar-brand-text { font-size: 14px; font-weight: 700; color: var(--gray-900); }
.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.sidebar-group {
  font-size: 11px; color: var(--gray-400);
  text-transform: uppercase; font-weight: 600; letter-spacing: .5px;
  padding: 14px 12px 6px;
}
.sidebar-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--r-sm);
  color: var(--gray-600); text-decoration: none;
  font-size: 13px; font-weight: 500;
  transition: background .15s, color .15s;
  cursor: pointer; background: none; border: none; width: 100%;
  text-align: left; font-family: inherit;
}
.sidebar-item:hover { background: var(--gray-100); color: var(--gray-900); }
.sidebar-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.sidebar-item i { font-size: 16px; }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--gray-200); flex-shrink: 0; }

.main-area { margin-left: 220px; min-height: 100vh; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 100; }
.sidebar-overlay.show { display: block; }
.mobile-menu-btn {
  display: none; background: none; border: none; padding: 6px;
  font-size: 22px; color: var(--gray-800); cursor: pointer; margin-right: 4px;
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .mobile-menu-btn { display: inline-flex; align-items: center; }
}

/* ── LAYOUT ──────────────────────────────────────────────────────────────── */
.content { max-width: 1400px; margin: 0 auto; padding: 24px; }
.container { max-width: 760px; margin: 0 auto; padding: 28px 24px 60px; }

/* ── BUTTONS ─────────────────────────────────────────────────────────────── */
.btn {
  padding: 8px 16px; border-radius: var(--r-sm); border: none;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all .15s; display: inline-flex; align-items: center; gap: 6px;
  font-family: inherit; line-height: 1.4;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary, .btn.primary { background: var(--primary); color: #fff; }
.btn-primary:hover, .btn.primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--gray-100); color: var(--gray-800); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #16a34a; }
.btn-ghost { background: #fff; border: 1px solid var(--gray-200); color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-50); border-color: var(--gray-400); }

/* ── FEATURE CARDS (포털 랜딩 그리드) ─────────────────────────────────────── */
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.feature-card {
  background: #fff; border: 1px solid var(--gray-200); border-radius: var(--r-lg);
  padding: 28px 24px; cursor: pointer; transition: all .2s;
  text-decoration: none; color: inherit;
  display: flex; flex-direction: column; gap: 16px;
}
.feature-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(49, 130, 246, .12);
  transform: translateY(-2px);
}
.feature-icon {
  width: 48px; height: 48px; border-radius: var(--r);
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.feature-card h3 { font-size: 17px; font-weight: 600; }
.feature-card p { font-size: 14px; color: var(--gray-500); line-height: 1.5; }
.feature-badge { display: inline-block; padding: 3px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; align-self: flex-start; }
.icon-blue  { background: var(--primary-light); color: var(--primary); }
.icon-green { background: var(--success-light); color: var(--success); }
.icon-gray  { background: var(--gray-100); color: var(--gray-400); }
.badge-active { background: #e8f3ff; color: var(--primary); }
.badge-soon   { background: var(--gray-100); color: var(--gray-400); }

/* ── TABLES ──────────────────────────────────────────────────────────────── */
.table-section { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--r); overflow: hidden; margin-bottom: 20px; }
.table-header { padding: 14px 20px; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; }
.table-header h3 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.table-header .count { background: var(--gray-100); color: var(--gray-600); padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; }
table { width: 100%; border-collapse: collapse; }
thead { background: var(--gray-50); }
th {
  padding: 10px 16px; text-align: left; font-size: 12px; font-weight: 600;
  color: var(--gray-500); text-transform: uppercase; letter-spacing: .3px;
  border-bottom: 1px solid var(--gray-200); white-space: nowrap;
}
td { padding: 10px 16px; font-size: 13px; border-bottom: 1px solid var(--gray-100); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }
.mono { font-family: 'SF Mono', Consolas, monospace; font-size: 12px; color: var(--gray-600); }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ── BADGES ──────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 5px; font-size: 11px; font-weight: 600; }
.badge-running, .badge-available { background: #dcfce7; color: #16a34a; }
.badge-stopped { background: #fee2e2; color: #dc2626; }
.badge-info    { background: #dbeafe; color: #2563eb; }

/* ── CHIPS (요약) ────────────────────────────────────────────────────────── */
.summary { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.chip {
  background: #fff; border: 1px solid var(--gray-200); border-radius: 10px;
  padding: 10px 16px; display: flex; align-items: center; gap: 8px;
  font-size: 13px; cursor: pointer; transition: all .15s; user-select: none;
}
.chip:hover { border-color: var(--primary); background: var(--primary-light); }
.chip.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); font-weight: 600; }
.chip-icon { width: 28px; height: 28px; border-radius: 7px; display: flex; align-items: center; justify-content: center; font-size: 14px; color: #fff; }
.chip-count { font-weight: 700; font-size: 15px; }

/* ── TOOLBAR ─────────────────────────────────────────────────────────────── */
.toolbar { background: #fff; border-bottom: 1px solid var(--gray-200); padding: 12px 24px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.toolbar .separator { width: 1px; height: 28px; background: var(--gray-200); }

/* ── FORM CONTROLS ───────────────────────────────────────────────────────── */
input[type="text"], input[type="password"], input[type="search"], input:not([type]), select, textarea {
  padding: 9px 12px; border: 1px solid var(--gray-200); border-radius: var(--r-sm);
  font-size: 13px; font-family: inherit; background: #fff; color: var(--gray-900);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(49, 130, 246, .1);
}
.panel { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--r); padding: 24px; box-shadow: var(--sh-sm); }
.panel > label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 18px; }
.panel input { display: block; width: 100%; margin-top: 6px; }
fieldset { border: 1px solid var(--gray-200); border-radius: var(--r); padding: 14px 16px 6px; margin: 6px 0 22px; }
legend { font-size: 13px; font-weight: 600; color: var(--gray-700); padding: 0 6px; }
.pillars { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.pill {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--gray-200); border-radius: var(--r-sm);
  font-size: 14px; cursor: pointer;
}
.pill:has(input:checked) { border-color: var(--primary); background: var(--primary-light); }

/* ── STATUS BANNERS ──────────────────────────────────────────────────────── */
.status { margin-top: 22px; padding: 16px; border-radius: var(--r); font-size: 14px; line-height: 1.5; }
.status.info { background: var(--primary-light); border: 1px solid var(--primary-mid); color: var(--primary-hover); }
.status.ok   { background: var(--success-light); border: 1px solid #b7e7c8; color: #145c33; }
.status.err  { background: var(--danger-light); border: 1px solid #f6c5c9; color: #8a1b22; }

/* ── TOAST ───────────────────────────────────────────────────────────────── */
.toast-wrap { position: fixed; top: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  background: #fff; border: 1px solid var(--gray-200); border-left: 4px solid var(--primary);
  border-radius: var(--r-sm); padding: 12px 16px; box-shadow: 0 4px 16px rgba(0, 0, 0, .08);
  font-size: 13px; color: var(--gray-800); min-width: 260px; max-width: 420px;
  display: flex; align-items: flex-start; gap: 10px; pointer-events: auto; animation: toast-in .2s ease-out;
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }
.toast i { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.toast.error i { color: var(--danger); }
.toast.success i { color: var(--success); }
.toast-msg { flex: 1; line-height: 1.5; word-break: break-word; }
.toast-close { background: none; border: none; color: var(--gray-400); cursor: pointer; padding: 0; font-size: 14px; line-height: 1; }
.toast-close:hover { color: var(--gray-600); }
@keyframes toast-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: translateX(0); } }

/* ── LOADING ─────────────────────────────────────────────────────────────── */
.loading-overlay { position: fixed; inset: 0; background: rgba(255, 255, 255, .8); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 200; gap: 16px; }
.loading-wrap { display: flex; align-items: center; justify-content: center; height: 60vh; flex-direction: column; gap: 16px; }
.spinner, .loading-spinner { width: 36px; height: 36px; border: 3px solid var(--gray-200); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
.spinner-sm { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--primary-mid); border-top-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; }
.loading-text { font-size: 14px; color: var(--gray-500); font-weight: 500; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── UTIL ────────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.empty { padding: 60px 24px; text-align: center; color: var(--gray-400); }
.empty i { font-size: 48px; margin-bottom: 12px; display: block; }
.empty p { font-size: 15px; }
