:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --text: #18212f;
  --muted: #647084;
  --line: #d9dee7;
  --accent: #1f6feb;
  --accent-soft: #e9f1ff;
  --sidebar: #151b29;
  --sidebar-muted: #aeb8c7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  background: var(--bg);
  color: var(--text);
  font-family: Arial, sans-serif;
}

.sidebar {
  min-height: 100vh;
  background: var(--sidebar);
  color: #fff;
  padding: 18px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  margin-bottom: 18px;
  font-size: 20px;
  font-weight: 700;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: #f4c542;
  color: #161616;
  font-size: 13px;
  font-weight: 800;
}

nav {
  display: grid;
  gap: 4px;
}

.nav-item {
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--sidebar-muted);
  padding: 9px 10px;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

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

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

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

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.current-user {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.25;
}

#pageSubtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary-button {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}

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

.material-control {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 760px;
  color: var(--muted);
  font-size: 14px;
}

.material-control[hidden] {
  display: none;
}

.material-control select {
  min-width: 170px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  font: inherit;
}

.material-control select:last-child {
  min-width: 260px;
}

.material-control input {
  width: 130px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  font: inherit;
}

.material-control button {
  min-height: 40px;
  white-space: nowrap;
}

.group-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.group-controls[hidden] {
  display: none;
}

.group-controls button {
  min-height: 40px;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.group-controls button:hover {
  background: var(--accent-soft);
  border-color: #bfd3f4;
}

input[type="search"] {
  width: min(420px, 100%);
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  font: inherit;
  background: #fff;
}

#status {
  min-width: 110px;
  color: var(--muted);
  font-size: 14px;
  text-align: right;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 148px);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
  table-layout: fixed;
}

th,
td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef2f7;
  color: #39465a;
  font-size: 13px;
  font-weight: 700;
  user-select: none;
}

.th-label {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-resizer {
  position: absolute;
  top: 0;
  right: -4px;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  z-index: 2;
}

.col-resizer:hover,
.is-resizing-column .col-resizer {
  background: rgba(31, 111, 235, 0.16);
}

.is-resizing-column {
  cursor: col-resize;
  user-select: none;
}

td {
  font-size: 14px;
  background: #fff;
}

tr:hover td {
  background: var(--accent-soft);
}

tr.selected-row td {
  background: #dfeaff;
}

.group-row td {
  background: #f8fafc;
  color: #18212f;
  font-weight: 700;
  padding: 0;
}

tr.group-row:hover td {
  background: #f8fafc;
}

.group-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  padding: 9px 11px;
  text-align: left;
  font: inherit;
}

.group-toggle:hover {
  background: var(--accent-soft);
}

.group-toggle-icon {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}

.template-dialog {
  width: min(520px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--text);
}

.template-dialog::backdrop {
  background: rgba(24, 33, 47, 0.35);
}

.template-dialog form {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.template-dialog h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.template-dialog label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 14px;
}

.template-dialog select,
.template-dialog input[type="text"],
.template-dialog input[type="number"],
.template-dialog input[type="password"] {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--text);
  font: inherit;
}

.template-dialog small {
  color: var(--muted);
  font-size: 12px;
}

.template-dialog .checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

#templateCancelBtn {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}

.login-page {
  display: block;
  grid-template-columns: none;
  background: #eef2f7;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 1.12fr) minmax(340px, 0.88fr);
}

.login-showcase {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  padding: 54px 56px 42px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
  color: #fff;
  background:
    linear-gradient(145deg, rgba(19, 24, 28, 0.94) 0%, rgba(43, 54, 59, 0.83) 48%, rgba(28, 20, 16, 0.72) 100%),
    url("/assets/images/login-stonecutter-hero.png") center bottom / cover no-repeat,
    #2f3438;
}

.login-showcase::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.32), transparent 42%),
    radial-gradient(circle at 74% 30%, rgba(239, 202, 133, 0.22), transparent 34%);
}

.login-brand,
.login-copy,
.login-metrics {
  position: relative;
  z-index: 1;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  color: #fff;
  font-weight: 800;
}

.login-brand-mark {
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: #e4bd72;
  color: #191815;
  font-size: 18px;
  font-weight: 900;
}

.login-brand-divider {
  width: 1px;
  height: 42px;
  background: rgba(255, 255, 255, 0.28);
}

.login-brand-wordmark {
  display: grid;
  gap: 3px;
}

.login-brand-wordmark strong,
.login-brand-wordmark span {
  display: block;
  line-height: 1.05;
}

.login-brand-wordmark strong {
  font-size: 1.26rem;
}

.login-brand-wordmark span {
  color: #e8cf9c;
  font-size: 1.05rem;
}

.login-copy h1 {
  max-width: 620px;
  margin: 0 0 14px;
  font-size: clamp(2.1rem, 3.4vw, 3.55rem);
  line-height: 1.08;
}

.login-copy p {
  max-width: 560px;
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 1rem;
  line-height: 1.65;
}

.login-points {
  display: grid;
  gap: 14px;
  max-width: 500px;
  margin: 30px 0 0;
  padding: 0;
  list-style: none;
}

.login-points li {
  display: flex;
  align-items: flex-start;
  gap: 13px;
}

.login-point-icon {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(228, 189, 114, 0.16);
  border: 1px solid rgba(232, 207, 156, 0.22);
  color: #f2d99e;
  font-weight: 900;
}

.login-points strong,
.login-points small {
  display: block;
}

.login-points strong {
  margin-bottom: 3px;
  color: rgba(255, 255, 255, 0.94);
  font-size: 0.98rem;
}

.login-points small {
  color: rgba(255, 255, 255, 0.66);
  font-size: 0.9rem;
  line-height: 1.4;
}

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

.login-metric {
  border-radius: 8px;
  padding: 15px 16px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.13);
  backdrop-filter: blur(10px);
}

.login-metric-value {
  display: block;
  margin-bottom: 5px;
  color: #f2d99e;
  font-size: 1.24rem;
  font-weight: 800;
}

.login-metric-label {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.84rem;
  line-height: 1.35;
}

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

.login-panel-card {
  width: min(440px, 100%);
  padding: 32px;
  border: 1px solid rgba(215, 223, 236, 0.95);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 45px rgba(24, 33, 47, 0.12);
}

.login-panel-title {
  margin: 0 0 8px;
  font-size: 1.72rem;
  line-height: 1.2;
}

.login-panel-subtitle {
  margin: 0 0 24px;
  color: var(--muted);
  line-height: 1.55;
}

.login-form {
  display: grid;
  gap: 0;
}

.login-field {
  margin-bottom: 16px;
}

.login-field label {
  display: block;
  margin-bottom: 8px;
  color: #344054;
  font-size: 0.86rem;
  font-weight: 700;
}

.login-field input,
.login-field select {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--text);
  font: inherit;
  background: #fff;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.login-field input:focus,
.login-field select:focus {
  outline: none;
  border-color: rgba(74, 108, 118, 0.72);
  box-shadow: 0 0 0 4px rgba(74, 108, 118, 0.12);
}

.login-submit {
  width: 100%;
  min-height: 46px;
  border-radius: 8px;
  background: #2f5d68;
  box-shadow: 0 14px 30px rgba(47, 93, 104, 0.24);
}

.login-submit:hover {
  background: #294f59;
}

.login-alert {
  display: none;
  margin-bottom: 16px;
  padding: 11px 13px;
  border: 1px solid #f3c2c2;
  border-radius: 8px;
  background: #fff3f3;
  color: #b42318;
  font-size: 14px;
}

@media (max-width: 860px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .workspace {
    padding: 14px;
  }

  .topbar,
  .toolbar {
    display: grid;
  }

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

  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-showcase {
    min-height: 430px;
    padding: 34px 24px 26px;
  }

  .login-metrics {
    grid-template-columns: 1fr;
  }

  #status {
    text-align: left;
  }
}

@media (max-width: 620px) {
  .login-showcase {
    min-height: 520px;
  }

  .login-points {
    gap: 12px;
  }

  .login-panel {
    padding: 24px 14px;
  }

  .login-panel-card {
    padding: 22px;
  }
}
