:root {
  --brand-primary: #156FB0;
  --brand-secondary: #3D9BDA;
  --brand-dark: #0A1628;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: #f4f6f9;
  color: #1a2233;
}
a { color: var(--brand-primary); text-decoration: none; }

/* Login page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
}
.login-box {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  width: 360px;
  box-shadow: 0 20px 50px rgba(0,0,0,.2);
}
.login-box h1 { font-size: 20px; margin-bottom: 4px; }
.login-box p.sub { color: #667; font-size: 13px; margin-bottom: 24px; }

/* Shell */
.admin-shell { display: flex; min-height: 100vh; width: 100%; }
.admin-sidebar {
  width: 220px;
  background: var(--brand-primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
  transition: width .18s ease;
}
.admin-sidebar__brand {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 8px; font-weight: 800; padding: 4px 12px 20px; font-size: 14px;
}
.admin-sidebar__brand img { width: 34px; height: 34px; border-radius: 9px; display: block; }
.admin-sidebar__brand-text { white-space: nowrap; }
.admin-sidebar nav { display: flex; flex-direction: column; flex: 1; }
.admin-sidebar nav a {
  display: flex; align-items: center; gap: 12px;
  color: #fff;
  font-weight: 600;
  padding: 11px 20px;
  font-size: 14px;
  border-left: 3px solid transparent;
}
.admin-sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.admin-sidebar nav a.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; border-left-color: #fff; }
.admin-sidebar .nav-icon { width: 22px; flex-shrink: 0; text-align: center; font-size: 19px; }
.admin-sidebar .nav-label { white-space: nowrap; overflow: hidden; }

/* Collapsed sidebar: icon-only */
.admin-sidebar.collapsed { width: 72px; }
.admin-sidebar.collapsed .admin-sidebar__brand-text { display: none; }
.admin-sidebar.collapsed nav a { justify-content: center; padding: 12px 0; }
.admin-sidebar.collapsed .nav-label { display: none; }

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Top bar + profile dropdown */
.admin-topbar {
  background: #fff;
  border-bottom: 1px solid #e7eaf0;
  padding: 14px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}
.admin-topbar__toggle {
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: #1a2233; padding: 8px 10px; border-radius: 8px;
}
.admin-topbar__toggle:hover { background: #f1f3f6; }
.admin-profile { position: relative; }
.admin-profile__btn {
  display: flex; align-items: center; gap: 8px;
  background: none; border: none; cursor: pointer;
  padding: 6px 10px; border-radius: 8px; font-family: inherit;
}
.admin-profile__btn:hover { background: #f1f3f6; }
.admin-profile__avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand-primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.admin-profile__name { font-size: 14px; font-weight: 600; color: #1a2233; }
.admin-profile__caret { font-size: 11px; color: #889; }
.admin-profile__menu {
  display: none;
  position: absolute; top: calc(100% + 6px); right: 0;
  background: #fff; border-radius: 10px; min-width: 180px;
  box-shadow: 0 8px 28px rgba(0,0,0,.14);
  overflow: hidden; z-index: 101;
}
.admin-profile.open .admin-profile__menu { display: block; }
.admin-profile__menu a { display: block; padding: 11px 16px; font-size: 14px; color: #1a2233; }
.admin-profile__menu a:hover { background: #f1f3f6; }

.admin-content { padding: 28px 40px; }
.admin-content h1 { font-size: 22px; margin-bottom: 4px; }
.admin-content p.page-sub { color: #667; font-size: 13px; margin-bottom: 22px; }

.alert { padding: 12px 16px; border-radius: 8px; font-size: 14px; margin-bottom: 18px; }
.alert--success { background: #dcfce7; color: #166534; }
.alert--error { background: #fee2e2; color: #991b1b; }

/* Card / table */
.card { background: #fff; border-radius: 12px; padding: 22px; margin-bottom: 24px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.card h2 { font-size: 16px; margin-bottom: 14px; color: var(--brand-primary); }
table.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.admin-table th, table.admin-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid #eef0f4; vertical-align: top; }
table.admin-table th { color: #667; font-weight: 600; font-size: 12px; text-transform: uppercase; }
table.admin-table img.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; background: #f1f3f6; }
table.admin-table .row-actions { display: flex; gap: 10px; white-space: nowrap; }
table.admin-table .row-actions form { display: inline; }

/* Forms */
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.form-row input[type=text], .form-row input[type=number], .form-row input[type=password],
.form-row textarea, .form-row select {
  width: 100%; padding: 9px 11px; border: 1px solid #d8dde5; border-radius: 8px; font-size: 14px; font-family: inherit;
}
.form-row textarea { min-height: 80px; resize: vertical; }
.form-row input:focus, .form-row textarea:focus, .form-row select:focus {
  border-color: var(--brand-primary); outline: 3px solid rgba(21,111,176,.15);
}
.form-row .hint { font-size: 12px; color: #889; margin-top: 4px; }
.form-row input[type=file] { padding: 6px 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.current-img { display: block; margin-bottom: 8px; max-width: 140px; max-height: 140px; border-radius: 8px; object-fit: cover; }

.btn {
  display: inline-block; padding: 10px 18px; border-radius: 8px; border: none;
  background: var(--brand-primary); color: #fff; font-weight: 600; font-size: 13px; cursor: pointer;
}
.btn:hover { background: var(--brand-secondary); }
.btn--sm { padding: 6px 12px; font-size: 12px; }
.btn--danger { background: #dc2626; }
.btn--danger:hover { background: #b91c1c; }
.btn--muted { background: #e5e7eb; color: #333; }
.btn--muted:hover { background: #d1d5db; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }

.table-scroll { overflow-x: auto; }

/* Responsive: tablet & mobile */
@media (max-width: 860px) {
  .admin-shell { flex-direction: column; }
  .admin-sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    padding: 10px 12px;
    overflow-x: auto;
    overflow-y: visible;
  }
  .admin-sidebar__brand { flex-direction: row; padding: 0 14px; white-space: nowrap; }
  .admin-sidebar nav { flex-direction: row; flex: none; }
  .admin-sidebar nav a { padding: 8px 12px; white-space: nowrap; }
  .admin-sidebar.collapsed { width: 100%; }
  .admin-sidebar.collapsed .admin-sidebar__brand-text,
  .admin-sidebar.collapsed .nav-label { display: inline; }
  .admin-topbar { padding: 10px 16px; position: static; }
  .admin-topbar__toggle { display: none; }
  .admin-content { padding: 18px 16px; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .login-box { width: 100%; max-width: 340px; padding: 28px 22px; }
  .admin-content h1 { font-size: 19px; }
  .admin-profile__name { display: none; }
  .card { padding: 16px; }
  table.admin-table { font-size: 12px; }
}

/* Image cropper */
.crop-overlay {
  position: fixed; inset: 0; background: rgba(10,22,40,.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.crop-modal {
  background: #fff; border-radius: 14px; padding: 22px;
  max-width: 92vw; box-shadow: 0 20px 60px rgba(0,0,0,.3);
  display: flex; flex-direction: column; align-items: center;
}
.crop-modal__title { font-size: 16px; margin-bottom: 4px; color: var(--brand-primary); align-self: flex-start; }
.crop-modal__hint { font-size: 12px; color: #889; margin-bottom: 14px; align-self: flex-start; }
.crop-frame {
  position: relative; overflow: hidden; border-radius: 8px;
  background: #111; touch-action: none; cursor: grab;
}
.crop-frame--round { border-radius: 50%; }
.crop-frame__img { position: absolute; left: 0; top: 0; user-select: none; pointer-events: none; }
.crop-zoom { width: 100%; margin-top: 14px; accent-color: var(--brand-primary); }
.crop-actions { display: flex; gap: 10px; margin-top: 16px; align-self: flex-end; }
