:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --ink: #121826;
  --muted: #667085;
  --line: #e6eaf2;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-soft: #e7f6f3;
  --sidebar: #101828;
  --sidebar-muted: #98a2b3;
  --danger: #e11d48;
  --danger-soft: #fff1f2;
  --shadow: 0 12px 30px rgba(16, 24, 40, 0.06);
  --radius: 16px;
  --sidebar-width: 248px;
  --font: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body.app-body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
}

button, input, select, textarea { font-family: inherit; }

.app-shell {
  min-height: 100vh;
}

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 22px 16px 18px;
  background: var(--sidebar);
  color: #fff;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 8px 28px;
  color: #fff;
  text-decoration: none;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-name {
  font-size: 16px;
  font-weight: 650;
  line-height: 1.25;
}

.app-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.app-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  color: var(--sidebar-muted);
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 600;
}

.app-nav a svg { flex: 0 0 auto; }

.app-nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }

.app-nav a.active {
  background: rgba(15, 118, 110, 0.22);
  color: #fff;
}

.nav-logout { margin-top: auto; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
}

.avatar, .avatar-lg {
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #1d2939;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.avatar { width: 34px; height: 34px; }
.avatar-lg { width: 42px; height: 42px; background: var(--accent-soft); color: var(--accent-strong); }

.sidebar-user .avatar { background: var(--accent); }

.sidebar-user strong {
  display: block;
  font-size: 13px;
  font-weight: 650;
}

.sidebar-user span {
  color: var(--sidebar-muted);
  font-size: 12px;
}

.app-main {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
  padding: 0 28px;
  background: var(--sidebar);
  color: #fff;
  border-bottom: 3px solid var(--accent);
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.12);
}

.nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.topbar-user {
  margin-left: auto;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}

.content-wrapper {
  flex: 1;
  padding: 8px 28px 32px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.page-head h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.03em;
}

.page-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.list-tools {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.list-tools input[type="search"] {
  width: min(100%, 280px);
}

.list-tools input,
.combo-input {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid #d0d5dd;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  outline: none;
}

.list-tools input:focus,
.combo-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.combo {
  position: relative;
  flex: 0 0 220px;
  width: 220px;
  max-width: 100%;
}

.combo-input { width: 100%; }

ul.combo-list {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  width: 100%;
  max-height: 240px;
  margin: 0;
  padding: 4px;
  overflow: auto;
  list-style: none;
  background: #fff;
  border: 1px solid #d0d5dd;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.12);
}

ul.combo-list li {
  display: block;
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  list-style: none;
  cursor: pointer;
}

ul.combo-list li::marker { content: ""; }

.combo-list li[hidden] { display: none; }

.combo-list li:hover,
.combo-list li.is-active { background: #f2f4f7; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 108px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
}

a.stat-card:hover { border-color: #b7e4dc; }

.stat-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
}

.stat-icon-items { background: #e0f2fe; color: #0369a1; }
.stat-icon-customers { background: #ecfdf3; color: #067647; }
.stat-icon-sales { background: #fffaeb; color: #b54708; }
.stat-icon-users { background: var(--accent-soft); color: var(--accent-strong); }

.stat-value {
  display: block;
  font-size: 28px;
  font-weight: 720;
  letter-spacing: -0.04em;
  line-height: 1;
}

.stat-label {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  padding: 14px 16px;
  text-align: left;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: #fbfcfe;
  border-bottom: 1px solid var(--line);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #f8fafc; }

.person {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
}

.muted { color: var(--muted); }

.role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #f2f4f7;
  color: #344054;
}

.role-1 { background: #ecfdf3; color: #067647; }
.role-2 { background: #eff8ff; color: #175cd3; }
.role-3 { background: #fff6ed; color: #c4320a; }

.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn, .btn-primary, .btn-ghost, .btn-danger, .btn-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}

.btn:hover, .btn-primary:hover { background: var(--accent-strong); color: #fff; }

.btn-ghost {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.btn-ghost:hover { background: #f8fafc; }

.btn-sm { min-height: 32px; padding: 0 10px; border-radius: 9px; font-size: 13px; }

.btn-info {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.btn-info:hover { background: #d7f0eb; color: var(--accent-strong); }

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-danger:hover { background: #ffe4e8; color: var(--danger); }

.alert {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
}

.alert-success { background: #ecfdf3; color: #067647; }
.alert-danger { background: var(--danger-soft); color: #be123c; }

.form-card { padding: 22px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 18px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
}

.field input, .field select, .field textarea, .form-control {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #d0d5dd;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  outline: none;
}

.field textarea { min-height: 84px; resize: vertical; }

.field input:focus, .field select:focus, .field textarea:focus, .form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.field small, .form-text {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.field-wide { grid-column: 1 / -1; }

.form-actions { margin-top: 18px; }

.file-input { padding: 8px; background: #fbfcfe; }

.image-preview { margin-bottom: 10px; }

.item-thumb,
.item-thumb-empty {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: #f2f4f7;
}

.item-thumb {
  display: block;
  object-fit: cover;
  border: 1px solid var(--line);
  background: #f8fafc;
}

.image-preview img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #f8fafc;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 28px 22px;
  color: var(--muted);
  font-size: 12px;
}

.app-footer a { color: var(--accent-strong); }

.sidebar-backdrop {
  display: none;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 420px at 10% -10%, rgba(15, 118, 110, 0.18), transparent 60%),
    radial-gradient(700px 380px at 110% 110%, rgba(16, 24, 40, 0.08), transparent 55%),
    var(--bg);
}

.login-card {
  width: min(100%, 420px);
  padding: 32px 28px 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  color: inherit;
  text-decoration: none;
}

.login-brand h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.03em;
}

.login-card > p {
  margin: -8px 0 22px;
  color: var(--muted);
}

.login-form { display: grid; gap: 14px; }

.login-form .btn { width: 100%; min-height: 46px; margin-top: 4px; }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 860px) {
  .nav-toggle { display: inline-grid; place-items: center; }
  .app-sidebar { transform: translateX(-105%); transition: transform 0.2s ease; }
  body.sidebar-open .app-sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 40, 0.45);
    z-index: 25;
  }
  .app-main { margin-left: 0; }
  .app-topbar, .content-wrapper, .app-footer { padding-left: 16px; padding-right: 16px; }
  .page-head, .list-tools { align-items: flex-start; flex-direction: column; }
  .list-tools input[type="search"], .list-tools .combo { width: 100%; flex-basis: auto; }
  .form-grid, .stat-grid { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 24px; }
}
