:root {
  --bg: #f4f7f6;
  --panel: #ffffff;
  --panel-soft: #eef4f1;
  --ink: #17201c;
  --muted: #66736d;
  --line: #d9e3df;
  --brand: #167c65;
  --brand-dark: #0f5949;
  --accent: #e0a21d;
  --danger: #c43f3f;
  --success: #208258;
  --shadow: 0 14px 34px rgba(23, 32, 28, 0.11);
  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(--ink);
}

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

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

form {
  margin: 0;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.1fr);
  background:
    linear-gradient(rgba(14, 30, 25, 0.62), rgba(14, 30, 25, 0.62)),
    url("https://images.unsplash.com/photo-1601944179066-29786cb9d32a?auto=format&fit=crop&w=1600&q=80") center/cover;
}

.login-brand {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px;
  color: white;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
  font-weight: 800;
}

.login-brand h1 {
  max-width: 620px;
  margin: 0;
  font-size: clamp(36px, 5vw, 72px);
  line-height: 0.98;
  letter-spacing: 0;
}

.login-brand p {
  max-width: 540px;
  font-size: 18px;
  color: rgba(255, 255, 255, 0.82);
}

.login-panel {
  display: grid;
  align-items: center;
  justify-items: center;
  padding: 28px;
}

.install-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.login-card,
.modal,
.panel,
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-card {
  width: min(420px, 100%);
  padding: 28px;
}

.login-card h2,
.section-title h2 {
  margin: 0;
  font-size: 24px;
}

.login-card p,
.section-title p {
  margin: 8px 0 0;
  color: var(--muted);
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 16px;
}

.field label {
  font-weight: 700;
  font-size: 13px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  background: #fbfdfc;
  color: var(--ink);
}

.field textarea {
  resize: vertical;
  min-height: 76px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 7px;
  color: white;
  background: var(--brand);
  font-weight: 800;
  white-space: nowrap;
}

.btn:hover {
  background: var(--brand-dark);
}

.btn.secondary {
  color: var(--ink);
  background: var(--panel-soft);
}

.btn.secondary:hover {
  background: #dfeae5;
}

.btn.danger {
  background: var(--danger);
}

.btn.icon {
  width: 38px;
  min-width: 38px;
  padding: 0;
}

.login-actions {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.hint {
  padding: 12px;
  border-radius: 7px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 13px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px;
  background: #13251f;
  color: white;
}

.sidebar-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar .brand-mark {
  background: var(--brand);
  border-color: transparent;
}

.sidebar-title strong {
  display: block;
}

.sidebar-title span {
  color: rgba(255, 255, 255, 0.62);
  font-size: 13px;
}

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

.nav button,
.nav a {
  display: flex;
  align-items: center;
  min-height: 42px;
  border-radius: 7px;
  color: rgba(255, 255, 255, 0.78);
  background: transparent;
  text-align: left;
  padding: 0 12px;
  font-weight: 700;
}

.nav button.active,
.nav button:hover,
.nav a.active,
.nav a:hover {
  color: white;
  background: rgba(255, 255, 255, 0.12);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

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

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

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: white;
  font-weight: 900;
}

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

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

.stat {
  padding: 18px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.alert-stats {
  margin-top: 14px;
}

.stat.alert {
  display: block;
  box-shadow: none;
}

.stat.alert.warn {
  border-color: #ebc663;
  background: #fff8df;
}

.stat.alert.danger {
  border-color: #efb1b1;
  background: #fff1f1;
}

.content-grid {
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.6fr);
  margin-top: 16px;
  align-items: start;
}

.panel {
  padding: 18px;
  box-shadow: none;
}

.narrow-panel {
  max-width: 720px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 12px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.table-wrap {
  overflow: hidden;
  box-shadow: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

th {
  color: var(--muted);
  background: #f7faf8;
  font-size: 12px;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
  color: var(--brand-dark);
  background: #dff3ec;
}

.pill.warn {
  color: #7a5200;
  background: #fff0c7;
}

.pill.danger {
  color: #8b2020;
  background: #ffe1e1;
}

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

.list-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.list-item strong {
  display: block;
}

.list-item span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}

.filters input,
.filters select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  background: white;
}

.empty {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #13251f;
  color: white;
  box-shadow: var(--shadow);
}

.notice {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--ink);
  font-weight: 700;
}

.notice.ok {
  border-color: #b9dfcf;
  background: #e4f5ee;
  color: var(--success);
}

.notice.error {
  border-color: #f1b7b7;
  background: #ffe9e9;
  color: var(--danger);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 27, 23, 0.58);
}

.modal {
  width: min(540px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 18px;
}

.inline-edit {
  position: relative;
}

.inline-edit summary {
  list-style: none;
}

.inline-edit summary::-webkit-details-marker {
  display: none;
}

.mini-form {
  position: absolute;
  right: 0;
  top: 44px;
  z-index: 12;
  width: 260px;
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.mini-form.wide {
  width: 360px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mini-form.wide textarea,
.mini-form.wide button,
.mini-form.wide .checkline {
  grid-column: 1 / -1;
}

.mini-form input,
.mini-form select,
.mini-form textarea {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
}

.mini-form textarea {
  min-height: 68px;
  padding: 8px 10px;
}

.checkline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.calendar-head {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

.calendar-day {
  min-height: 132px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.muted-day {
  background: #eef4f1;
}

.calendar-event {
  display: block;
  margin-top: 8px;
  padding: 7px;
  border-radius: 7px;
  background: #dff3ec;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
}

.calendar-event.warn {
  background: #fff0c7;
  color: #7a5200;
}

.calendar-event.danger {
  background: #ffe1e1;
  color: #8b2020;
}

.preview-box {
  min-height: 72px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  color: var(--ink);
  line-height: 1.5;
  white-space: pre-wrap;
}

.hidden {
  display: none !important;
}

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

  .login-brand {
    min-height: 38vh;
    padding: 28px;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    gap: 12px;
  }

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

  .sidebar-footer {
    margin-top: 0;
  }

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

@media (max-width: 640px) {
  .workspace {
    padding: 16px;
  }

  .topbar,
  .section-title,
  .list-item {
    align-items: stretch;
    flex-direction: column;
  }

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

  table {
    min-width: 980px;
  }

  .nav {
    grid-template-columns: 1fr;
  }
}
