/* sing-box panel — v3 redesign */

/* ── Reset & base ────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; padding: 0;
  background: #0d1117; color: #c9d1d9;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  font-size: 14px; line-height: 1.5;
}
code, pre, .mono, input[type=text], select, textarea, .tag, .obtag {
  font-family: 'SF Mono', 'Cascadia Code', 'Consolas', 'JetBrains Mono', monospace;
}

/* ── Layout shell ────────────────────────────────────── */
.shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #010409;
  border-right: 1px solid #21262d;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}
.sidebar-brand {
  padding: 1.1rem 1rem .8rem;
  border-bottom: 1px solid #21262d;
}
.sidebar-brand h1 {
  font-size: 1rem;
  font-weight: 600;
  color: #58a6ff;
  margin: 0;
  letter-spacing: -0.02em;
}
.sidebar-brand .brand-sub {
  font-size: .72rem;
  color: #484f58;
  margin-top: .15rem;
}
.sidebar-section {
  padding: .6rem 0;
  border-bottom: 1px solid #21262d0a;
}
.sidebar-section:last-of-type {
  margin-top: auto;
  border-top: 1px solid #21262d;
  border-bottom: none;
}
.sidebar-label {
  padding: .2rem 1rem;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #484f58;
  font-weight: 600;
}
.sidebar a, .sidebar button.nav-link {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .38rem 1rem;
  color: #8b949e;
  text-decoration: none;
  font-size: .85rem;
  border: none;
  background: none;
  width: 100%;
  cursor: pointer;
  text-align: left;
  transition: color .15s, background .15s;
}
.sidebar a:hover, .sidebar button.nav-link:hover {
  color: #c9d1d9;
  background: #161b22;
}
.sidebar a.active {
  color: #58a6ff;
  background: #1f6feb18;
  border-right: 2px solid #58a6ff;
}
.sidebar .nav-icon {
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  font-size: .9rem;
}
.sidebar .nav-badge {
  margin-left: auto;
  font-size: .7rem;
  padding: 1px 5px;
  border-radius: 8px;
  background: #30363d;
  color: #8b949e;
}

/* ── Main content ────────────────────────────────────── */
.main {
  flex: 1;
  min-width: 0;
  padding: 1.4rem 2rem;
  max-width: 1100px;
}

/* ── Page header ─────────────────────────────────────── */
.page-header {
  margin-bottom: 1rem;
  padding-bottom: .6rem;
  border-bottom: 1px solid #21262d;
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-header h2 {
  margin: 0;
  font-size: 1.2rem;
  color: #e6edf3;
  font-weight: 600;
}
.page-header .subtitle {
  color: #6e7681;
  font-size: .82rem;
}

/* ── Headings ────────────────────────────────────────── */
h2 { color: #e6edf3; font-size: 1.1rem; margin-top: 1.4rem;
     border-bottom: 1px solid #21262d; padding-bottom: .3rem; font-weight: 600; }
h3 { color: #8b949e; font-size: .95rem; margin-top: 1rem; font-weight: 500; }

/* ── Tables ──────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; margin: .4rem 0; }
th, td { padding: .38rem .6rem; text-align: left; border-bottom: 1px solid #21262d; vertical-align: middle; }
th { color: #8b949e; font-weight: 500; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }

/* ── Tags / badges ───────────────────────────────────── */
.tag {
  background: #1f6feb22; color: #58a6ff;
  padding: 2px 7px; border-radius: 4px; font-size: .8rem;
  white-space: nowrap;
}
.obtag {
  background: #1f6feb15; color: #58a6ff;
  padding: 1px 6px; border-radius: 3px; font-size: .78rem;
}
.stat-badge {
  background: #30363d; color: #8b949e;
  padding: 1px 6px; border-radius: 4px; font-size: .72rem;
}

/* ── Row kinds ───────────────────────────────────────── */
.system-fixed-row { color: #6e7681; }
.system-fixed-row .tag { background: #30363d22; color: #8b949e; }
.system-editable-row .tag { background: #8b6dad33; color: #bc8cff; }
.custom-row .tag { background: #bf872022; color: #d29922; }
.category-row { background: #161b2244; }
.disabled-row td { opacity: .5; font-style: italic; }

/* ── Forms & inputs ──────────────────────────────────── */
input[type=text], input[type=password], select, textarea {
  background: #161b22; color: #c9d1d9;
  border: 1px solid #30363d;
  padding: .35rem .5rem; border-radius: 5px;
  font-size: .88rem;
  transition: border-color .15s;
}
input[type=text]:focus, input[type=password]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #58a6ff;
  box-shadow: 0 0 0 2px #1f6feb33;
}
input[type=text] { min-width: 16rem; }
form.inline { display: inline; }
.add-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin: .5rem 0; }

/* ── Buttons ─────────────────────────────────────────── */
button, .btn {
  background: #238636; color: #fff;
  border: none; padding: .35rem .8rem;
  border-radius: 5px; cursor: pointer;
  font-size: .83rem; font-weight: 500;
  transition: background .15s;
  display: inline-flex; align-items: center; gap: .3rem;
}
button:hover, .btn:hover { background: #2ea043; }
button.del, .btn-danger { background: #da3633; }
button.del:hover, .btn-danger:hover { background: #f85149; }
button.move, .btn-secondary { background: #30363d; color: #c9d1d9; }
button.move:hover, .btn-secondary:hover { background: #484f58; }
button.toggle { background: #30363d; color: #8b949e; }
button.toggle.on { background: #238636; color: #fff; }
.cat-controls { display: flex; gap: .25rem; }

/* ── Flash messages ──────────────────────────────────── */
.msg {
  padding: .55rem .8rem; margin: .5rem 0; border-radius: 5px;
  font-size: .88rem;
  background: #1f6feb18; color: #58a6ff;
  border-left: 3px solid #1f6feb;
}
.msg.err {
  background: #da363318; color: #f85149;
  border-left-color: #da3633;
  white-space: pre-wrap;
}
.msg.warn {
  background: #bf872018; color: #d29922;
  border-left-color: #bf8720;
}
.msg.ok {
  background: #23863618; color: #3fb950;
  border-left-color: #238636;
}

/* ── Draft banner ────────────────────────────────────── */
.draft-banner {
  background: #bf872022; border: 1px solid #bf8720;
  border-radius: 5px; padding: .55rem .8rem; margin: .5rem 0;
}
.draft-banner button { margin-left: .4rem; }
.draft-banner .btn, .draft-banner input { margin-left: .4rem; vertical-align: middle; }
.draft-banner input.draft-msg {
  padding: .28rem .45rem; width: 16rem; max-width: 38vw;
  background: #0d1117; border: 1px solid #30363d; border-radius: 4px; color: #c9d1d9;
}
.draft-summary { margin: .6rem 0; }
.draft-summary li { margin: .15rem 0; }
pre.diff { background: #0d1117; border: 1px solid #30363d; border-radius: 6px;
  padding: .7rem .9rem; overflow-x: auto; font-size: .82rem; line-height: 1.35; }
pre.diff .add { color: #3fb950; }
pre.diff .del { color: #f85149; }
pre.diff .hdr { color: #58a6ff; }

/* ── Links ───────────────────────────────────────────── */
a { color: #58a6ff; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Login page ──────────────────────────────────────── */
.login-box {
  max-width: 340px; margin: 15vh auto; padding: 2rem;
  background: #161b22; border: 1px solid #30363d;
  border-radius: 8px; text-align: center;
}
.login-box h1 { font-size: 1.3rem; color: #58a6ff; margin-bottom: 1.2rem; }
.login-box input[type=password] {
  width: 100%; margin-bottom: .8rem;
}
.login-box button { width: 100%; padding: .5rem; }

/* ── Mobile ──────────────────────────────────────────── */
.mobile-header {
  display: none;
  position: sticky; top: 0; z-index: 101;
  background: #010409; border-bottom: 1px solid #21262d;
  padding: .6rem 1rem;
  align-items: center; justify-content: space-between;
}
.mobile-header h1 { font-size: .95rem; color: #58a6ff; margin: 0; }
.hamburger {
  background: none; border: none; color: #8b949e;
  font-size: 1.4rem; cursor: pointer; padding: .2rem .4rem;
}
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}

@media (max-width: 768px) {
  .mobile-header { display: flex; }
  .sidebar {
    position: fixed;
    left: -240px;
    transition: left .2s ease;
    width: 240px;
  }
  .sidebar.open { left: 0; }
  .sidebar-overlay.open { display: block; }
  .main { padding: 1rem; }
}

/* ── Utility ─────────────────────────────────────────── */
.ghost { color: #f0883e; }
.text-muted { color: #8b949e; }
.text-sm { font-size: .82rem; }
.text-xs { font-size: .78rem; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.w-full { width: 100%; }

/* ── Dashboard cards ──────────────────────────────────── */
.dash-card {
  background: #161b22;
  border: 1px solid #21262d;
  border-radius: 8px;
  padding: 1rem 1.2rem;
}
.dash-card-label {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #484f58;
  font-weight: 600;
  margin-bottom: .3rem;
}
.dash-card-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: .2rem;
}
.dash-card-detail {
  font-size: .78rem;
  color: #8b949e;
}

/* ── Responsive grid fallback ────────────────────────── */
@media (max-width: 768px) {
  div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

/* ── HTMX indicators ────────────────────────────────── */
.htmx-indicator {
  opacity: 0;
  transition: opacity .2s;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}
