:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #eef3f7;
  --text: #16202a;
  --muted: #657386;
  --line: #d8e0e8;
  --primary: #126a72;
  --primary-dark: #0c5056;
  --danger: #b3261e;
  --ok: #1f7a4d;
  --shadow: 0 20px 48px rgba(25, 37, 49, 0.14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 480px) minmax(0, 1fr);
}

.login-panel {
  background: var(--surface);
  padding: clamp(28px, 6vw, 72px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid var(--line);
}

.login-visual {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #12343b, #295b5f 48%, #7b8d69);
}

.login-visual::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(255,255,255,.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.08) 1px, transparent 1px);
  background-size: 56px 56px;
}

.login-visual-content {
  position: absolute;
  left: clamp(32px, 8vw, 96px);
  right: clamp(32px, 8vw, 96px);
  bottom: clamp(32px, 8vw, 96px);
  color: white;
}

.login-visual-content h1 { margin: 0 0 16px; font-size: clamp(36px, 5vw, 68px); line-height: 1; letter-spacing: 0; }
.login-visual-content p { margin: 0; max-width: 620px; font-size: 18px; line-height: 1.55; color: rgba(255,255,255,.82); }

.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 40px; }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 8px; background: var(--primary); color: white; font-weight: 800; }
.brand strong { display: block; font-size: 18px; }
.brand small { display: block; color: var(--muted); margin-top: 2px; }

.login-panel h2 { margin: 0 0 8px; font-size: 30px; letter-spacing: 0; }
.login-panel p { margin: 0 0 28px; color: var(--muted); line-height: 1.5; }

.form-grid { display: grid; gap: 14px; }
.field { display: grid; gap: 7px; }
.field span { font-size: 13px; color: var(--muted); font-weight: 650; }
.input, .select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: white;
  color: var(--text);
}
.input:focus, .select:focus, textarea:focus { outline: 2px solid rgba(18,106,114,.18); border-color: var(--primary); }

.button {
  border: 0;
  border-radius: 8px;
  padding: 11px 14px;
  background: var(--primary);
  color: white;
  font-weight: 750;
  cursor: pointer;
  min-height: 42px;
}
.button:hover { background: var(--primary-dark); }
.button.secondary { background: var(--surface-soft); color: var(--text); border: 1px solid var(--line); }
.button.secondary:hover { background: #e5edf3; }
.button.danger { background: #f8e9e7; color: var(--danger); border: 1px solid #efc9c4; }
.button:disabled { opacity: .55; cursor: not-allowed; }

.alert { display: none; padding: 10px 12px; border-radius: 8px; background: #fff0ee; color: var(--danger); border: 1px solid #efc9c4; }
.alert.show { display: block; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { background: #17232d; color: white; padding: 22px; display: flex; flex-direction: column; gap: 22px; }
.sidebar .brand { margin: 0; }
.sidebar .brand small { color: rgba(255,255,255,.58); }
.nav { display: grid; gap: 8px; }
.nav-item { border: 0; border-radius: 8px; background: transparent; color: rgba(255,255,255,.76); text-align: left; padding: 11px 12px; cursor: pointer; }
.nav-item.active, .nav-item:hover { color: white; background: rgba(255,255,255,.11); }
.sidebar-footer { margin-top: auto; display: grid; gap: 10px; }
.user-chip { color: rgba(255,255,255,.78); font-size: 13px; line-height: 1.4; }

.main { padding: 28px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.topbar h1 { margin: 0 0 4px; font-size: 28px; letter-spacing: 0; }
.topbar p { margin: 0; color: var(--muted); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(22, 32, 42, .05); padding: 18px; }
.panel + .panel { margin-top: 16px; }
.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; }

.modules { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.module-card { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 20px; min-height: 178px; display: flex; flex-direction: column; justify-content: space-between; box-shadow: 0 8px 24px rgba(22, 32, 42, .05); }
.module-card h2 { margin: 0 0 8px; font-size: 22px; letter-spacing: 0; }
.module-card p { margin: 0; color: var(--muted); line-height: 1.5; }
.module-icon { width: 42px; height: 42px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-soft); color: var(--primary); font-weight: 850; margin-bottom: 16px; }
.module-card footer { margin-top: 22px; display: flex; justify-content: flex-end; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 11px 10px; text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 750; background: var(--surface-soft); color: var(--muted); }
.badge.good { background: #e8f5ee; color: var(--ok); }
.badge.bad { background: #fff0ee; color: var(--danger); }
.actions { display: flex; gap: 8px; justify-content: flex-end; }

.permissions { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; }
.check { display: flex; gap: 8px; align-items: center; min-height: 36px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }

.dialog-shell { min-width: min(720px, calc(100vw - 28px)); border: 0; padding: 0; }
dialog { border: 0; border-radius: 10px; padding: 0; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(8, 15, 22, .42); }
.dialog-shell header, .dialog-shell footer { padding: 16px 18px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.dialog-shell footer { border-top: 1px solid var(--line); border-bottom: 0; justify-content: flex-end; gap: 10px; }
.dialog-shell h2 { margin: 0; font-size: 20px; }
#dialog-body { padding: 18px; }
.icon-button { border: 0; background: transparent; width: 34px; height: 34px; border-radius: 8px; cursor: pointer; }
.icon-button:hover { background: var(--surface-soft); }
.user-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.user-form .full { grid-column: 1 / -1; }

@media (max-width: 820px) {
  .login-page { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .main { padding: 18px; }
  .topbar { flex-direction: column; }
  .user-form { grid-template-columns: 1fr; }
}
