:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel-strong: #fefefe;
  --text: #172033;
  --muted: #68758d;
  --line: #e1e6f0;
  --blue: #245fdf;
  --blue-dark: #184bb2;
  --green: #0f8f76;
  --amber: #b7791f;
  --red: #c2413b;
  --shadow: 0 18px 50px rgba(24, 36, 64, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top left, #e8f0ff 0, transparent 30%), var(--bg);
  color: var(--text);
}

body.menu-open {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
}

.login-panel {
  width: min(760px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 40px;
  box-shadow: var(--shadow);
}

.brand-row,
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--blue), var(--green));
  color: white;
  font-weight: 800;
  font-size: 24px;
}

.brand-mark.small {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.08;
}

h2 {
  font-size: 28px;
  line-height: 1.15;
}

h3 {
  font-size: 18px;
}

.login-copy {
  max-width: 620px;
  margin: 28px 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
}

.login-state {
  margin-top: 24px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f9fbff;
}

.login-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-top: 12px;
  padding: 0 18px;
  border-radius: 12px;
  color: white;
  background: var(--blue);
  text-decoration: none;
  font-weight: 700;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
  background: #101827;
  color: white;
}

.sidebar-brand strong {
  display: block;
}

.sidebar-brand span,
.sidebar-user small {
  color: #aeb8cc;
}

.sidebar-close,
.sidebar-open {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 24px;
  line-height: 1;
}

.sidebar-close {
  margin-left: auto;
  color: white;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-open {
  flex: 0 0 auto;
  color: var(--text);
  background: white;
  border-color: var(--line);
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  text-align: left;
  color: #d7deee;
  background: transparent;
}

.nav-item:hover,
.nav-item.active {
  color: white;
  background: rgba(255, 255, 255, 0.11);
}

.sidebar-user {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.workspace {
  min-width: 0;
  padding: 28px;
}

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

.topbar > div {
  min-width: 0;
}

.content {
  display: grid;
  gap: 18px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.two-column {
  grid-template-columns: minmax(320px, 0.9fr) minmax(420px, 1.35fr);
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 8px 26px rgba(24, 36, 64, 0.06);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-header p,
.empty,
.hint {
  margin: 6px 0 0;
  color: var(--muted);
}

.stat-card strong {
  display: block;
  font-size: 30px;
  line-height: 1;
}

.stat-card span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid.two {
  grid-template-columns: 1fr 1fr;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 650;
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.4;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(36, 95, 223, 0.12);
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.success-button {
  min-height: 40px;
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 750;
}

.primary-button {
  color: white;
  background: var(--blue);
}

.primary-button:hover {
  background: var(--blue-dark);
}

.secondary-button {
  color: var(--text);
  background: white;
  border-color: var(--line);
}

.ghost-button {
  color: #d7deee;
  background: rgba(255, 255, 255, 0.08);
}

.danger-button {
  color: white;
  background: var(--red);
}

.success-button {
  color: white;
  background: var(--green);
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcff;
}

.list-item.selectable {
  cursor: pointer;
}

.list-item.selectable.active,
.list-item.selectable:hover {
  border-color: rgba(36, 95, 223, 0.45);
  background: #f3f7ff;
}

.item-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 800;
}

.meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
  background: #edf2ff;
  color: var(--blue);
}

.badge.green {
  background: #e9f8f4;
  color: var(--green);
}

.badge.amber {
  background: #fff7e8;
  color: var(--amber);
}

.badge.red {
  background: #fff0f0;
  color: var(--red);
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: 420px;
  padding: 14px 16px;
  color: white;
  background: #101827;
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.toast.error {
  background: var(--red);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 24;
  background: rgba(16, 24, 39, 0.42);
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: min(320px, calc(100vw - 32px));
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 180ms ease;
    box-shadow: 0 18px 50px rgba(24, 36, 64, 0.22);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-open,
  .sidebar-close {
    display: inline-flex;
  }

  .topbar {
    align-items: flex-start;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .topbar .secondary-button {
    margin-left: auto;
  }

  .grid.stats,
  .two-column,
  .form-grid.two {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .login-screen,
  .workspace,
  .sidebar {
    padding: 18px;
  }

  .login-panel {
    padding: 24px;
  }

  h1 {
    font-size: 28px;
  }

  h2 {
    font-size: 24px;
  }

  .topbar .secondary-button,
  .sidebar-open {
    min-height: 42px;
  }

  .workspace {
    padding-top: 20px;
  }
}
