/* Guldidar Admin — CRM Premium Theme */

:root {
  --sidebar-w: 248px;
  --primary: #3b71fe;
  --primary-dark: #2a5ae8;
  --primary-soft: #eef3ff;
  --primary-glow: rgba(59, 113, 254, .18);
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1b2559;
  --muted: #8f9bba;
  --border: #e9edf7;
  --danger: #ee5d50;
  --success: #05cd99;
  --warn: #ffb547;
  --info: #3965ff;
  --teal: #0ea5e9;
  --orange: #ff9f43;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 8px 24px rgba(27, 37, 89, .04);
  --shadow-hover: 0 12px 32px rgba(27, 37, 89, .08);
  --sidebar-text: #707eae;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  direction: ltr;
}

a { color: var(--primary); text-decoration: none; transition: color .15s; }
a:hover { color: var(--primary-dark); }

.layout { display: flex; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  background: #fff;
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  border-right: 1px solid var(--border);
  border-left: none;
}

.brand {
  padding: 26px 22px 20px;
}
.brand-name {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.3px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
}
.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, #3b71fe, #6a9bff);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  font-size: 16px;
  box-shadow: 0 8px 18px rgba(59, 113, 254, .35);
}
.brand-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  padding-left: 50px;
  padding-right: 0;
  font-weight: 500;
}

.menu {
  flex: 1;
  padding: 6px 14px 20px;
  overflow-y: auto;
}
.menu-label {
  font-size: 11px;
  letter-spacing: .06em;
  color: #a3aed0;
  padding: 16px 14px 8px;
  font-weight: 700;
  text-transform: uppercase;
}
.menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  margin: 2px 0;
  border-radius: 12px;
  color: var(--sidebar-text);
  font-weight: 500;
  transition: .18s ease;
}
.menu a:hover {
  background: #f6f8fe;
  color: var(--text);
}
.menu a.active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(59, 113, 254, .28);
}
.menu a.active .ico svg { stroke: #fff; }
.menu .ico {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.menu .ico svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-foot {
  padding: 16px 20px 22px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

/* ===== Main ===== */
.main {
  margin-left: var(--sidebar-w);
  margin-right: 0;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 72px;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.4px;
  color: var(--text);
}
.topbar-search {
  flex: 1;
  max-width: 420px;
  position: relative;
}
.topbar-search input {
  width: 100%;
  height: 44px;
  border: none;
  background: #f4f7fe;
  border-radius: 999px;
  padding: 0 18px 0 44px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  font-family: inherit;
  direction: ltr;
  text-align: left;
}
.topbar-search input::placeholder { color: #a3aed0; }
.topbar-search .search-ico {
  position: absolute;
  left: 16px;
  right: auto;
  top: 50%;
  transform: translateY(-50%);
  color: #a3aed0;
  display: grid;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
}
.topbar-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #f4f7fe;
  display: grid;
  place-items: center;
  color: var(--text);
  position: relative;
}
.topbar-icon .dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid #fff;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 4px 12px;
  background: #f4f7fe;
  border-radius: 999px;
}
.user-chip .hi {
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b71fe, #8b5cf6);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
}
.btn-logout {
  height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.btn-logout:hover { color: var(--danger); border-color: #fecaca; }

.content {
  padding: 26px 28px 48px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-head h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -.5px;
}
.page-head .sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}
.chip-select {
  height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
}

/* ===== KPI Cards ===== */
.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 22px;
}
@media (max-width: 1200px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .cards { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { margin-right: 0; margin-left: 0; }
  .topbar-search { display: none; }
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px 20px;
  box-shadow: var(--shadow);
  border: 1px solid transparent;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  transition: transform .18s, box-shadow .18s;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}
.stat-card .meta { min-width: 0; }
.stat-card .label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.stat-card .value {
  font-size: 28px;
  font-weight: 800;
  margin-top: 8px;
  letter-spacing: -.6px;
  color: var(--text);
  line-height: 1.1;
}
.stat-card .hint {
  margin-top: 10px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.stat-card .hint.up { color: var(--success); }
.stat-card .hint.down { color: var(--danger); }
.stat-card .hint.muted { color: var(--muted); font-weight: 500; }
.stat-ico {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.stat-ico svg { width: 22px; height: 22px; }
.stat-ico.blue { background: #eef3ff; color: var(--primary); }
.stat-ico.teal { background: #e0f7ff; color: var(--teal); }
.stat-ico.orange { background: #fff4e5; color: var(--orange); }
.stat-ico.green { background: #e6faf4; color: var(--success); }

/* ===== Panels ===== */
.panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid transparent;
  margin-bottom: 20px;
  overflow: hidden;
}
.panel-hd {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.panel-hd h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.panel-bd { padding: 18px 22px; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  transition: .15s;
  font-family: inherit;
  box-shadow: 0 6px 16px rgba(59, 113, 254, .25);
}
.btn:hover { background: var(--primary-dark); color: #fff; }
.btn-outline {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
  box-shadow: none;
}
.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}
.btn-danger { background: var(--danger); box-shadow: 0 6px 16px rgba(238, 93, 80, .25); }
.btn-danger:hover { background: #dc4a3e; }
.btn-sm { padding: 7px 12px; font-size: 12px; box-shadow: none; }
.btn-link {
  background: transparent;
  color: var(--primary);
  border: none;
  padding: 4px 6px;
  box-shadow: none;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn-link.danger { color: var(--danger); }

.form-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  align-items: start;
  margin-bottom: 16px;
}
.form-row label {
  padding-top: 11px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.form-control {
  width: 100%;
  max-width: 520px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  background: #fff;
  outline: none;
  transition: border .15s, box-shadow .15s;
  font-family: inherit;
  color: var(--text);
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
}
textarea.form-control { min-height: 100px; resize: vertical; }
select.form-control { max-width: 280px; }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
}
table.data th, table.data td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
table.data th {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  background: #fafbff;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: .03em;
}
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #fafbff; }
table.data .avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  object-fit: cover;
  background: #eef3ff;
}
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge-ok { background: #e6faf4; color: #05a87e; }
.badge-off { background: #f4f7fe; color: #8f9bba; }
.badge-wait { background: #fff4e5; color: #d97706; }
.badge-pay { background: #eef3ff; color: var(--primary); }

.pager {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.alert {
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 500;
}
.alert-success { background: #e6faf4; color: #05a87e; }
.alert-error { background: #ffeceb; color: #d6453d; }
.alert-info { background: #eef3ff; color: var(--primary); }

.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.35fr .85fr;
  gap: 18px;
}
.grid-dash {
  display: grid;
  grid-template-columns: 1.4fr .8fr;
  gap: 18px;
  margin-bottom: 18px;
}
.grid-dash-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
@media (max-width: 1100px) {
  .grid-2, .grid-dash, .grid-dash-2 { grid-template-columns: 1fr; }
}

/* Charts */
.chart-box { position: relative; min-height: 220px; }
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 14px;
}
.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.chart-legend i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.donut-wrap {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  justify-content: center;
}
.donut {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
}
.donut-hole {
  position: absolute;
  inset: 28px;
  background: #fff;
  border-radius: 50%;
  display: grid;
  place-items: center;
  text-align: center;
}
.donut-hole strong {
  display: block;
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
}
.donut-hole small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.bars {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 160px;
  padding-top: 10px;
}
.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  height: 100%;
  justify-content: flex-end;
}
.bar {
  width: 100%;
  max-width: 28px;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, #6a9bff, #3b71fe);
  min-height: 4px;
  transition: height .3s;
}
.bar-col em {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}
.quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.quick-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  background: #f4f7fe;
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  transition: .15s;
}
.quick-item:hover {
  background: var(--primary-soft);
  color: var(--primary);
}
.quick-item .qi {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #fff;
  display: grid;
  place-items: center;
  color: var(--primary);
  box-shadow: var(--shadow);
}

/* Login */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse at 10% 20%, rgba(59,113,254,.18), transparent 45%),
    radial-gradient(ellipse at 90% 80%, rgba(139,92,246,.12), transparent 40%),
    linear-gradient(160deg, #f5f7fb 0%, #eef3ff 50%, #f8fafc 100%);
  padding: 24px;
}
.login-card {
  width: 420px;
  max-width: calc(100vw - 32px);
  background: #fff;
  border-radius: 24px;
  padding: 40px 36px 32px;
  box-shadow: 0 24px 64px rgba(27, 37, 89, .1);
  border: 1px solid rgba(233, 237, 247, .8);
}
.login-card .logo-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.login-card h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.4px;
}
.login-card .desc {
  color: var(--muted);
  margin: 0 0 28px;
  font-size: 13px;
  font-weight: 500;
}
.login-card .form-row {
  grid-template-columns: 1fr;
  gap: 8px;
}
.login-card .form-row label {
  padding-top: 0;
  font-weight: 600;
  color: var(--text);
}
.login-card .form-control { max-width: none; }
.login-card .btn {
  width: 100%;
  padding: 13px;
  margin-top: 10px;
  font-size: 15px;
  border-radius: 14px;
}
.login-foot {
  margin-top: 20px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.thumb-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.thumb-list img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
}

code {
  background: #f4f7fe;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--primary);
}

/* Image upload field */
.img-field-box { max-width: 560px; }
.img-field-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.img-field-row .form-control {
  flex: 1;
  max-width: none;
}
.img-field-btn {
  flex-shrink: 0;
  height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  border: 1px solid transparent;
  user-select: none;
}
.img-field-btn:hover {
  background: var(--primary);
  color: #fff;
}
.img-field-status {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  min-height: 18px;
}
.img-field-status.loading { color: var(--muted); }
.img-field-status.ok { color: var(--success); }
.img-field-status.err { color: var(--danger); }
.img-field-preview-wrap { margin-top: 10px; }
.img-field-preview {
  max-width: 220px;
  max-height: 220px;
  border-radius: 14px;
  border: 1px solid var(--border);
  object-fit: cover;
  background: #f4f7fe;
  display: block;
}
.img-field-compact { max-width: 320px; }
.img-field-compact-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.img-field-compact .img-field-preview-wrap {
  margin-top: 0;
  flex-shrink: 0;
}
.img-field-compact .img-field-preview {
  width: 72px;
  height: 72px;
  max-width: 72px;
  max-height: 72px;
  border-radius: 12px;
}
.img-field-empty {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: #f4f7fe;
  color: var(--muted);
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4px;
  box-sizing: border-box;
}
.img-field-multi-preview { max-width: 520px; }
.img-field-multi-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.img-field-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.img-field-thumb {
  position: relative;
  width: 72px;
  height: 72px;
}
.img-field-thumbs img,
.img-field-thumb img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f4f7fe;
  display: block;
}
.img-field-thumb-rm {
  position: absolute;
  top: -6px;
  left: -6px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: #e5484d;
  color: #fff;
  font-size: 14px;
  line-height: 22px;
  padding: 0;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
}
.img-field-thumb-rm:hover { background: #c9373b; }

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
.media-card {
  background: #fafbff;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  transition: .15s;
}
.media-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.media-card img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
  background: #eef3ff;
}
.media-card .media-meta {
  padding: 10px 12px 12px;
}
.media-card .media-name {
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
  margin-bottom: 8px;
  max-height: 34px;
  overflow: hidden;
}
.media-card .media-actions {
  display: flex;
  gap: 6px;
}
.media-card .media-actions .btn { flex: 1; box-shadow: none; }
