:root {
  --bg: #eef3f8;
  --bg-accent: #dceaf6;
  --card: #fff;
  --text: #102033;
  --muted: #5b6b7c;
  --accent: #1f76cb;
  --accent-hover: #1864ad;
  --accent-soft: #e7f1fb;
  --success: #0f7a4d;
  --success-soft: #e9f8f0;
  --danger: #c0352b;
  --danger-soft: #fdecea;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --border: #dce4ee;
  --sidebar: #0b1f33;
  --sidebar-2: #102a44;
  --sidebar-text: #d7e3ef;
  --shadow: 0 10px 30px rgba(16, 32, 51, .07);
  --radius: 16px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { max-width: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(900px 420px at 100% -10%, var(--bg-accent), transparent 55%),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
}
img, svg, video { max-width: 100%; height: auto; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font-family: inherit; }

.login-page {
  min-height: 100vh;
  background:
    radial-gradient(800px 380px at 8% 0%, rgba(31, 118, 203, .45), transparent 55%),
    radial-gradient(700px 420px at 100% 100%, rgba(14, 165, 164, .18), transparent 50%),
    #0b1f33;
}
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card, .card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.login-card {
  width: 100%;
  max-width: 420px;
  padding: 36px 32px 32px;
}
.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 24px;
}
.login-brand img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  margin-bottom: 14px;
}
.login-brand h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -.02em;
}
.login-brand p { margin: 6px 0 0; }
.login-card .btn { width: 100%; margin-top: 6px; }

.layout {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: var(--sidebar-text);
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 18px;
  padding: 4px 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  background: #fff;
  border-radius: 12px;
  padding: 4px;
  flex-shrink: 0;
}
.brand-text { min-width: 0; }
.brand-text strong {
  display: block;
  font-size: 13px;
  line-height: 1.3;
  color: #fff;
}
.brand-text span {
  display: block;
  font-size: 11px;
  color: #93a8bc;
  margin-top: 2px;
}
.sidebar h1 { font-size: 16px; margin: 0; line-height: 1.3; }
.menu-toggle, .menu-close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: #1e293b;
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.menu-close { background: rgba(255,255,255,.08); }
.nav-backdrop { display: none; }
.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  flex: 1;
  padding-right: 4px;
}
.nav-label {
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #8aa0b5;
  padding: 14px 12px 6px;
  font-weight: 700;
}
.nav-label:first-child { padding-top: 2px; }
.sidebar nav a,
.sidebar-foot a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sidebar-text);
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  position: relative;
}
.sidebar nav a i,
.sidebar-foot a i {
  width: 1.15em;
  text-align: center;
  opacity: .85;
}
.sidebar nav a span,
.sidebar-foot a span { flex: 1; min-width: 0; }
.sidebar nav a:hover,
.sidebar-foot a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar nav a.active {
  background: rgba(31, 118, 203, .28);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--accent);
}
.nav-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sidebar-foot {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-foot a { color: var(--sidebar-text); }
.main { padding: 22px 24px 40px; min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow);
}
.topbar h2 { margin: 0; flex: 1; min-width: 0; font-size: 20px; letter-spacing: -.02em; }
.topbar-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 42%;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
}
h2 { margin: 0 0 16px; font-size: 22px; }
h3 {
  margin: 0 0 16px;
  font-size: 15px;
  letter-spacing: -.01em;
}
.card h3 {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  color: #1b334d;
}
.card + .card { margin-top: 16px; }
.card-narrow { max-width: 520px; }
.page-lead { margin: 0 0 18px; color: var(--muted); max-width: 62ch; }
label { display: block; font-size: 13px; margin: 0 0 6px; color: var(--muted); font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=tel], input[type=datetime-local], input[type=file], select, textarea {
  width: 100%;
  max-width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 12px;
  font: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(31, 118, 203, .15);
}
textarea { min-height: 110px; resize: vertical; }
textarea.tall { min-height: 220px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, transform .15s, box-shadow .15s;
}
.btn:hover { background: var(--accent-hover); }
.btn-secondary { background: #1e3a5f; }
.btn-secondary:hover { background: #16314f; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { filter: brightness(1.05); }
.btn-sm { padding: 7px 10px; font-size: 13px; font-weight: 600; }
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.table th, .table td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: left; font-size: 14px; vertical-align: top; }
.table th { background: #f7fafc; color: var(--muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #f8fbfe; }
.flash {
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-weight: 600;
  font-size: 14px;
}
.flash.ok { background: var(--success-soft); color: var(--success); }
.flash.err { background: var(--danger-soft); color: var(--danger); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; min-width: 0; }
.muted { color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
  color: inherit;
  min-width: 0;
  transition: transform .16s ease, box-shadow .16s ease;
}
a.stat:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px rgba(31, 118, 203, .12);
  color: inherit;
}
.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
  font-size: 18px;
}
.stat-copy { min-width: 0; }
.stat strong {
  display: block;
  font-size: 24px;
  letter-spacing: -.03em;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stat small, .stat .stat-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}
.stat.alert .stat-icon { background: var(--warn-soft); color: var(--warn); }
.stat.alert.has-new .stat-icon { background: var(--danger-soft); color: var(--danger); }
.thumb { max-width: 120px; max-height: 80px; object-fit: cover; border-radius: 10px; display: block; margin-bottom: 8px; }
label:has(input[type=checkbox]) {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 8px;
}
label input[type=checkbox] { width: auto; margin: 3px 0 0; accent-color: var(--accent); }
.table form { display: inline; }
.table-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 16px;
}
.icon-field { margin-bottom: 12px; }
.icon-field-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.icon-field-row input { margin-bottom: 0; }
.icon-preview {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 20px;
}
.icon-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 4px;
}
.icon-pick {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: #334155;
  cursor: pointer;
}
.icon-pick:hover, .icon-pick:focus {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.notice {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.notice-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.notice h3 { border: 0; padding: 0; margin: 0 0 6px; }
.notice ul { margin: 8px 0 0; padding-left: 18px; }
.empty-state {
  text-align: center;
  padding: 42px 20px;
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
}
.empty-state i { font-size: 28px; color: var(--accent); margin-bottom: 10px; display: block; }
.form-actions { margin-top: 8px; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .menu-toggle, .menu-close { display: inline-flex; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 88vw);
    height: 100%;
    z-index: 40;
    transform: translateX(-110%);
    transition: transform .22s ease;
    overflow-y: auto;
    box-shadow: none;
  }
  body.nav-open { overflow: hidden; }
  body.nav-open .sidebar { transform: translateX(0); box-shadow: 12px 0 40px rgba(0,0,0,.35); }
  .nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(11, 31, 51, .5);
    backdrop-filter: blur(2px);
    z-index: 30;
  }
  body.nav-open .nav-backdrop { display: block; }
  .main { padding: 14px 14px 32px; }
  .topbar { flex-wrap: wrap; padding: 12px; }
  .topbar h2 { font-size: 17px; }
  .topbar-email { max-width: 100%; flex-basis: 100%; order: 3; }
  .card, .login-card { padding: 16px; }
  .grid-2, .stats { grid-template-columns: 1fr; }
  .table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .actions .btn { min-height: 40px; }
}
