:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e3e6ea;
  --border-strong: #cbd2da;
  --text: #1c2127;
  --text-muted: #6b7480;
  --primary: #1c2127;
  --primary-hover: #000000;
  --accent: #f5b81c;
  --accent-hover: #e0a60e;
  --dark: #000000;
  --success-bg: #e7f6ec;
  --success-text: #1a7f3c;
  --warning-bg: #fdf0e0;
  --warning-text: #b06a13;
  --danger: #dc2626;
  --radius: 10px;
  --radius-sm: 7px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.right { text-align: right; }
.center { text-align: center; }

.contacts-badge {
  display: inline-block;
  min-width: 28px;
  padding: 2px 8px;
  border-radius: 6px;
  background: #f0f2f5;
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
}

/* ---------- LOGIN ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-logo {
  background: var(--dark);
  border-radius: 12px;
  padding: 18px 24px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  width: fit-content;
}
.login-logo img {
  height: 38px;
  width: auto;
  display: block;
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; font-weight: 600; }
.login-sub { color: var(--text-muted); margin: 0 0 24px; font-size: 13px; }
.login-card form { text-align: left; }
.login-card label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 14px 0 6px;
}

input[type="text"], input[type="password"], input[type="email"], select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245,184,28,.18);
}

#login-btn {
  width: 100%;
  margin-top: 22px;
  padding: 11px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
#login-btn:hover { background: var(--primary-hover); }
#login-btn:disabled { opacity: .6; cursor: default; }

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin: 12px 0 0;
  min-height: 18px;
}

/* ---------- TOPBAR ---------- */
.topbar {
  background: var(--dark);
  border-bottom: 1px solid var(--dark);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar-left {
  display: flex; align-items: center; gap: 12px;
}
.topbar-logo {
  height: 26px;
  width: auto;
  display: block;
}
.topbar-sep {
  color: #ffffff;
  font-weight: 500;
  font-size: 14px;
  padding-left: 12px;
  border-left: 1px solid rgba(255,255,255,.2);
}
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-right .muted { color: rgba(255,255,255,.65); }

/* ---------- BUTTONS ---------- */
.btn-ghost {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: background .15s;
}
.btn-ghost:hover { background: #f0f2f5; }
.btn-ghost.icon-only { padding: 6px 10px; }

.topbar-right .btn-ghost {
  background: rgba(255,255,255,.1);
  border-color: rgba(255,255,255,.2);
  color: #ffffff;
}
.topbar-right .btn-ghost:hover {
  background: rgba(255,255,255,.18);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: .6; }

/* ---------- CONTAINER ---------- */
.container { max-width: 1100px; margin: 0 auto; padding: 24px; }

.stats-row { display: flex; gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 18px;
  min-width: 150px;
}
.stat-label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.stat-value { display: block; font-size: 26px; font-weight: 600; }

/* ---------- TOOLBAR ---------- */
.toolbar { display: flex; gap: 12px; margin-bottom: 16px; }
.search-box { flex: 1; position: relative; display: flex; align-items: center; }
.search-box svg { position: absolute; left: 12px; color: var(--text-muted); }
.search-box input { padding-left: 36px; }

/* ---------- TABLE ---------- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}
td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }

.user-cell { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: #1c2127;
  color: #ffffff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
  flex-shrink: 0;
}
.user-name { font-weight: 500; }

.badge {
  display: inline-block;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 6px;
  font-weight: 500;
}
.badge-active { background: var(--success-bg); color: var(--success-text); }
.badge-suspended { background: var(--warning-bg); color: var(--warning-text); }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn {
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 5px 9px;
  cursor: pointer;
  color: var(--text-muted);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: #f0f2f5; color: var(--text); }

.loading-cell, .empty-cell {
  text-align: center;
  color: var(--text-muted);
  padding: 32px;
}

/* ---------- PAGINATION ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}
.page-buttons { display: flex; gap: 8px; }

/* ---------- EDIT PANEL ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20,24,30,.45);
  display: flex;
  justify-content: flex-end;
  z-index: 100;
}
.edit-panel {
  background: var(--surface);
  width: 460px;
  max-width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,.12);
}
.edit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.edit-header h2 { font-size: 17px; margin: 0; font-weight: 600; }
.edit-body { padding: 22px; overflow-y: auto; flex: 1; }

.field-group { margin-bottom: 16px; }
.field-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin: 24px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.section-title:first-child { margin-top: 0; }

.edit-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.save-status { font-size: 13px; margin-top: 12px; min-height: 18px; }
.save-status.ok { color: var(--success-text); }
.save-status.err { color: var(--danger); }

.readonly-field {
  background: #f5f6f8;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .edit-panel { width: 100%; }
  th:nth-child(3), td:nth-child(3) { display: none; }
}
