:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #172026;
  --muted: #63717a;
  --line: #dce3e7;
  --accent: #126a72;
  --accent-soft: #d8edef;
  --danger: #ad3434;
  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);
}

a {
  color: inherit;
}

.login-page,
.app-page {
  min-height: 100vh;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card,
.panel {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(23, 32, 38, 0.08);
}

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

.sidebar {
  padding: 24px;
  background: #10191e;
  color: #f7fafb;
}

.brand {
  display: grid;
  gap: 4px;
  margin-bottom: 28px;
}

.brand span,
.muted {
  color: var(--muted);
}

.sidebar .muted {
  color: #a9b6bd;
}

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

.nav a {
  border-radius: 8px;
  padding: 11px 12px;
  color: #dce4e8;
  text-decoration: none;
}

.nav a.active,
.nav a:hover {
  background: #1d2a30;
  color: white;
}

.workspace {
  padding: 28px;
}

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

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 14px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface);
}

.panel {
  width: 100%;
}

.table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

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

.table th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.status-pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
}

.metric span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
}

label {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  font: inherit;
}

textarea {
  resize: vertical;
}

select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: white;
  font: inherit;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

button,
.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--accent);
  color: white;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}

.danger {
  border-color: #f2c7c7;
  color: var(--danger);
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}

.table .inline-form {
  align-items: center;
}

.inline-form label {
  min-width: 150px;
  margin-top: 0;
}

.table .inline-form label {
  min-width: 120px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
}

.form-grid label {
  margin-top: 0;
}

.user-form,
.record-form {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: end;
  column-gap: 16px;
  row-gap: 14px;
}

.user-form label,
.record-form label {
  grid-column: span 4;
}

.user-form .wide-field,
.record-form .wide-field {
  grid-column: span 6;
}

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

.color-field {
  grid-column: span 2;
  max-width: none;
}

.color-field input[type="color"] {
  width: 56px;
  min-width: 56px;
  height: 42px;
  padding: 4px;
  cursor: pointer;
  background: white;
}

.collapsible-panel {
  padding: 0;
  overflow: hidden;
}

.section-summary,
.user-card-heading {
  cursor: pointer;
  list-style: none;
}

.section-summary::-webkit-details-marker,
.user-card-heading::-webkit-details-marker {
  display: none;
}

.section-summary {
  padding: 20px 24px;
}

.section-summary strong,
.section-summary small {
  display: block;
}

.section-summary strong {
  font-size: 1.35rem;
}

.section-summary small {
  margin-top: 4px;
  color: var(--muted);
  font-weight: 600;
}

.collapsible-panel > .user-form,
.collapsible-panel > .record-form {
  padding: 0 24px 24px;
}

.panel-note {
  padding: 0 24px 24px;
}

.password-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.password-grid label {
  grid-column: span 5;
}

.form-grid button,
.password-grid button {
  justify-self: start;
  margin-top: 8px;
}

.user-form button,
.record-form button {
  grid-column: 1 / -1;
}

.password-grid button {
  grid-column: span 2;
}

.user-card-list {
  display: grid;
  gap: 18px;
}

.record-list {
  display: grid;
  gap: 18px;
}

.user-card,
.record-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: #fbfcfd;
  overflow: hidden;
}

.user-card-heading,
.record-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 0;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
}

.record-heading::-webkit-details-marker {
  display: none;
}

.user-card[open] .user-card-heading,
.record-card[open] .record-heading {
  border-bottom: 1px solid var(--line);
}

.user-main strong,
.user-main span,
.record-heading strong,
.record-heading small {
  display: block;
}

.user-main span,
.record-heading small {
  color: var(--muted);
  font-size: 0.9rem;
}

.user-card-body,
.record-card .record-form {
  padding: 18px 16px 22px;
}

.compact-form {
  padding-top: 8px;
}

.compact-form button,
.compact-form .button {
  align-self: end;
}

.subtask-block {
  margin: 0 16px 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.subtask-block h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.subtask-form {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.subtask-form + .subtask-form {
  margin-top: 10px;
}

.subtask-form label {
  grid-column: span 3;
  margin-top: 0;
}

.subtask-form .wide-field {
  grid-column: span 4;
}

.subtask-form button {
  grid-column: span 2;
  justify-self: start;
  margin-top: 8px;
}

.new-subtask-form {
  background: #f7fafb;
}

.line-form {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.line-form + .line-form {
  margin-top: 10px;
}

.line-form label {
  grid-column: span 2;
  margin-top: 0;
}

.line-form .line-description {
  grid-column: span 4;
}

.line-form button {
  grid-column: span 2;
  justify-self: start;
  margin-top: 8px;
}

.line-total {
  align-self: center;
  justify-self: start;
  color: var(--ink);
}

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

.success {
  border-radius: 8px;
  padding: 10px 12px;
  background: #dff3e8;
  color: #19633a;
  font-weight: 700;
}

.error {
  border-radius: 8px;
  padding: 10px 12px;
  background: #fde8e8;
  color: var(--danger);
  font-weight: 700;
}

@media (max-width: 820px) {
  .app-shell,
  .grid,
  .form-grid,
  .password-grid,
  .user-form,
  .record-form,
  .subtask-form,
  .line-form {
    grid-template-columns: 1fr;
  }

  .user-form label,
  .record-form label,
  .user-form .wide-field,
  .record-form .wide-field,
  .record-form .full-field,
  .color-field,
  .password-grid label,
  .user-form button,
  .record-form button,
  .subtask-form label,
  .subtask-form .wide-field,
  .subtask-form button,
  .line-form label,
  .line-form .line-description,
  .line-form button,
  .password-grid button {
    grid-column: auto;
  }
}
