@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&family=Space+Grotesk:wght@500;600;700&display=swap');

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --slate: #0f172a;
  --white: #ffffff;
  --red: #e11d48;
  --red-hover: #be123c;
  --mid: #334155;
  --light: #f1f5f9;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --success-text: #166534;
  --error-bg: #fef2f2;
  --error-border: #fecaca;
  --error-text: #991b1b;
  --mono: 'JetBrains Mono', monospace;
  --display: 'Space Grotesk', sans-serif;
  --body: 'Inter', sans-serif;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body {
  font-family: var(--body);
  color: var(--text);
  background: var(--white);
  height: 100%;
  line-height: 1.5;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  max-width: 100vw;
  overflow-y: auto;
}

body > main {
  padding: 48px 32px;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
  min-height: 100vh;
}

/* ===== CONSOLE FONT UTILITY ===== */
.mono {
  font-family: var(--mono);
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
}

/* ===== LOGIN PAGE - SPLIT SCREEN ===== */
.login-container {
  display: flex;
  min-height: 100vh;
}

.login-panel {
  width: 45%;
  background: var(--slate);
  color: var(--white);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 60px 40px;
  position: relative;
  overflow: hidden;
}

.login-panel::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 40px,
    rgba(255, 255, 255, 0.015) 40px,
    rgba(255, 255, 255, 0.015) 41px
  ),
  repeating-linear-gradient(
    90deg,
    transparent,
    transparent 40px,
    rgba(255, 255, 255, 0.015) 40px,
    rgba(255, 255, 255, 0.015) 41px
  );
  animation: gridScroll 30s linear infinite;
}

@keyframes gridScroll {
  0% { transform: translate(0, 0); }
  100% { transform: translate(40px, 40px); }
}

.login-panel-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 320px;
}

.login-panel-content .logo-icon {
  width: 56px;
  height: 56px;
  background: var(--red);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 30px;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--white);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

.login-panel-content h1 {
  font-family: var(--display);
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.login-panel-content p {
  font-size: 0.875rem;
  color: #94a3b8;
  line-height: 1.6;
}

.login-form-side {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 60px 40px;
  background: var(--white);
}

.login-form {
  width: 100%;
  max-width: 380px;
}

.login-form h2 {
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--slate);
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

.login-form .form-hint {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 36px;
}

/* ===== FORM ELEMENTS ===== */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-family: var(--display);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--mid);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 0;
  font-family: var(--body);
  font-size: 1rem;
  color: var(--text);
  background: var(--white);
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--red);
}

.form-group input::placeholder {
  color: #cbd5e1;
}

/* ===== BUTTONS ===== */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 0;
  cursor: pointer;
  font-family: var(--display);
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: var(--red);
  color: var(--white);
  width: 100%;
  border: 2px solid var(--red);
}

.btn-primary:hover {
  background: var(--red-hover);
  border-color: var(--red-hover);
}

.btn-success {
  background: #15803d;
  color: var(--white);
  border: 2px solid #15803d;
}

.btn-success:hover {
  background: #166534;
  border-color: #166534;
}

.btn-danger {
  background: var(--red);
  color: var(--white);
  border: 2px solid var(--red);
}

.btn-danger:hover {
  background: var(--red-hover);
  border-color: var(--red-hover);
}

.btn-secondary {
  background: var(--white);
  color: var(--mid);
  border: 2px solid var(--border);
}

.btn-secondary:hover {
  background: var(--light);
  border-color: var(--mid);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.75rem;
}

/* ===== MESSAGES ===== */
.message {
  padding: 12px 16px;
  border: 2px solid;
  border-radius: 0;
  margin-bottom: 20px;
  font-size: 0.875rem;
  font-weight: 500;
  display: none;
}

.message.show {
  display: block;
}

.message.error {
  background: var(--error-bg);
  color: var(--error-text);
  border-color: var(--error-border);
}

.message.success {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: var(--success-border);
}

/* ===== HEADER ===== */
.header {
  background: var(--white);
  border-bottom: 2px solid var(--border);
  padding: 0 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header .logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.header .logo-icon-small {
  width: 32px;
  height: 32px;
  background: var(--slate);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-family: var(--display);
  font-size: 0.875rem;
  font-weight: 700;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

.header h2 {
  font-family: var(--display);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--slate);
  letter-spacing: -0.01em;
}

.header .user-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header .user-info span {
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ===== DASHBOARD LAYOUT ===== */
.dashboard-layout {
  display: flex;
  height: calc(100vh - 64px);
  background: var(--light);
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 300px;
  background: var(--white);
  border-right: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 2px solid var(--border);
  background: var(--light);
}

.sidebar-header span {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.sidebar-content {
  display: flex;
  flex-direction: column;
}

/* ===== SIDEBAR GROUP ===== */
.sidebar-group {
  border-bottom: 2px solid var(--border);
}

.sidebar-group-header {
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--white);
  cursor: default;
}

.sidebar-group-header span:first-child {
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.875rem;
}

/* ===== SIDEBAR LIST ===== */
.sidebar-list {
  list-style: none;
}

.sidebar-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.sidebar-list a:hover {
  background: var(--light);
  color: var(--red);
  border-left-color: var(--red);
}

.sidebar-list a.item-active {
  background: var(--light);
  color: var(--red);
  border-left-color: var(--red);
  font-weight: 600;
}

.sidebar-list svg {
  flex-shrink: 0;
  color: var(--text-muted);
  width: 12px;
  height: 12px;
}

.sidebar-list a:hover svg,
.sidebar-list a.item-active svg {
  color: var(--red);
}

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  overflow-y: auto;
  background: var(--light);
}

.content-container {
  height: 100%;
}

.welcome-panel {
  padding: 60px 40px;
  text-align: center;
  background: var(--white);
}

.welcome-panel h2 {
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--slate);
}

.welcome-panel p {
  color: var(--text-muted);
  font-size: 0.9375rem;
}

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: 4px 10px;
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 2px solid;
  border-radius: 0;
}

.badge-admin {
  background: var(--red);
  color: var(--white);
  border-color: var(--red);
}

.badge-default {
  background: transparent;
  color: var(--slate);
  border-color: var(--slate);
}

.badge-operator {
  background: #fef3c7;
  color: #92400e;
  border-color: #fbbf24;
}

/* ===== ADMIN PANEL ===== */
.admin-section {
  background: var(--white);
  border: 2px solid var(--border);
  padding: 28px 32px;
  margin-top: 24px;
}

.admin-section > h3 {
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--slate);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding-bottom: 12px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--red);
  display: flex;
  align-items: center;
  gap: 8px;
}

.accounts-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.account-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--light);
  border: 2px solid var(--border);
  border-radius: 0;
  transition: border-color 0.2s;
}

.account-item:hover {
  border-color: var(--slate);
}

.account-info .username {
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--slate);
}

.account-info .username + div {
  margin-top: 4px;
}

.account-info .username + div .badge {
  margin-right: 4px;
}

.account-status {
  font-family: var(--mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border: 2px solid;
  border-radius: 0;
}

.account-status.active {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: var(--success-border);
}

.account-status.inactive {
  background: var(--error-bg);
  color: var(--error-text);
  border-color: var(--error-border);
}

.account-actions {
  display: flex;
  gap: 8px;
}

/* ===== MODAL ===== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.75);
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal.show {
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: var(--white);
  border: 2px solid var(--border);
  padding: 32px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-header h3 {
  font-family: var(--display);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--slate);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.close-modal {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--body);
  line-height: 1;
  padding: 4px;
}

.close-modal:hover {
  color: var(--slate);
}

/* ===== GROUPS CHECKBOX ===== */
.groups-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 0;
}

.groups-list label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--light);
  cursor: pointer;
  border: 2px solid var(--border);
  transition: all 0.2s;
  font-family: var(--display);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mid);
  user-select: none;
}

.groups-list label:hover {
  border-color: var(--mid);
}

.groups-list input {
  accent-color: var(--red);
}

.groups-list label:has(input:checked) {
  background: var(--slate);
  color: var(--white);
  border-color: var(--slate);
}

/* ===== ACCESS STATUS BADGE (signature) ===== */
.status-bar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--success-bg);
  border: 2px solid var(--success-border);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--success-text);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 24px;
}

.status-bar .dot {
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 0;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .login-panel {
    display: none;
  }

  .login-form-side {
    padding: 40px 24px;
  }

  .header {
    padding: 0 16px;
  }

  .dashboard-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 2px solid var(--border);
    max-height: 50vh;
  }

  .admin-section {
    padding: 20px;
  }

  .modal-content {
    margin: 16px;
    padding: 24px;
  }
}

/* ===== FOCUS STATE ===== */
button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 2px;
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
