:root {
  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-strong: #174798;
  --line: #dce2eb;
  --text: #17243a;
  --muted: #61708a;
  --accent: #e84e0e;
  --accent-strong: #174798;
  --warning: #e84e0e;
  --brand-blue-soft: #e9eff9;
  --brand-orange-soft: #fff0e9;
  --shadow: 0 5px 18px rgba(23, 50, 91, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
}

button {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.auth-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: var(--brand-blue-soft);
}

.auth-panel {
  width: min(420px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-top: 6px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 34px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.auth-panel .brand-mark {
  background: #ffffff;
}

.auth-brand-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-form {
  display: grid;
  gap: 18px;
  margin-top: 26px;
}

.auth-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.auth-form input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

.auth-form input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(232, 78, 14, 0.16);
}

.auth-submit {
  min-height: 44px;
  justify-content: center;
}

.auth-message {
  min-height: 20px;
  margin: 18px 0 0;
  color: #9b2c2c;
  font-size: 13px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--surface-strong);
  color: #eef3f7;
  padding: 22px 13px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: #ffffff;
  color: #f5f8fb;
  font-weight: 700;
  overflow: hidden;
}

.brand-logo {
  width: auto;
  max-width: none;
  height: 56px;
  transform: translateX(-1px);
}

.brand-title,
.brand-subtitle,
.eyebrow,
.metric-label {
  margin: 0;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
}

.brand-subtitle {
  margin-top: 4px;
  color: #c9d7ef;
  font-size: 12px;
}

.sidebar-nav {
  display: grid;
  gap: 10px;
  margin-top: 28px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #e2eaf7;
  text-align: left;
  cursor: pointer;
}

.nav-item svg {
  width: 21px;
  height: 21px;
  flex: 0 0 21px;
  stroke-width: 2;
}

.nav-item:hover,
.nav-item.active {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 7px 18px rgba(109, 34, 5, 0.2);
}

.main-content {
  min-width: 0;
  padding: 24px 28px 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid #e9edf3;
}

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

h1,
h2 {
  margin: 6px 0 0;
  line-height: 1.15;
}

h1 {
  color: #123d7d;
  font-size: 30px;
}

h2 {
  font-size: 20px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #20a36a;
}

.user-session,
.session-identity {
  display: flex;
  align-items: center;
}

.user-session {
  gap: 10px;
}

.session-identity {
  gap: 8px;
  min-height: 38px;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.section-hidden {
  display: none !important;
}

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  position: relative;
  min-height: 128px;
  padding: 18px 58px 16px 25px;
  border-left: 7px solid var(--surface-strong);
  overflow: hidden;
}

.metric-card:nth-child(3n + 2) {
  border-left-color: var(--accent);
}

.metric-icon {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: var(--brand-blue-soft);
  color: var(--surface-strong);
}

.metric-card:nth-child(3n + 2) .metric-icon {
  background: var(--brand-orange-soft);
  color: var(--accent);
}

.metric-icon svg {
  width: 20px;
  height: 20px;
  stroke-width: 2.2;
}

.metric-card strong {
  display: block;
  margin-top: 14px;
  color: var(--accent-strong);
  font-size: 32px;
  line-height: 1;
}

.metric-card span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.metric-label {
  max-width: 100%;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.secondary-button svg {
  width: 17px;
  height: 17px;
}

.module-content {
  padding: 18px;
}

.panel {
  min-height: 260px;
  overflow: hidden;
  box-shadow: 0 3px 13px rgba(23, 50, 91, 0.06);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
}

.module-placeholder {
  display: grid;
  place-items: center;
  min-height: 190px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.compact-placeholder {
  min-height: 150px;
}

.dashboard-detail {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.8fr);
  gap: 16px;
}

.dashboard-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #ffffff;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(23, 50, 91, 0.05);
}

.wide-dashboard-card {
  min-width: 0;
}

.dashboard-card-header {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.dashboard-card-header h3 {
  margin: 4px 0 0;
  color: #123d7d;
  font-size: 16px;
}

.life-chart {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.chart-row {
  display: grid;
  grid-template-columns: minmax(150px, 220px) minmax(140px, 1fr) 58px;
  align-items: center;
  gap: 12px;
}

.chart-label {
  display: grid;
  gap: 2px;
}

.chart-label strong,
.chart-label span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-label span,
.muted-text {
  color: var(--muted);
  font-size: 13px;
}

.chart-track {
  height: 12px;
  border: 0;
  border-radius: 999px;
  background: #e7ebf0;
  overflow: hidden;
}

.chart-bar {
  height: 100%;
  border-radius: 999px;
}

.chart-value {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: right;
}

.featured-tool {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.featured-photo,
.photo-preview {
  display: grid;
  place-items: center;
  min-height: 210px;
  border: 1px solid var(--line);
  background: var(--brand-blue-soft);
  color: var(--muted);
  overflow: hidden;
}

.featured-photo img,
.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.featured-info {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
}

.featured-info p {
  margin: 0;
}

.tool-form {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

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

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

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--surface-strong);
  outline: 3px solid rgba(23, 71, 152, 0.13);
}

textarea {
  resize: vertical;
}

.wide-field {
  grid-column: 1 / -1;
}

.photo-preview {
  width: min(520px, 100%);
  min-height: 180px;
  margin-top: 16px;
}

.form-actions,
.table-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.form-actions {
  margin-top: 16px;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
}

.primary-button:hover {
  background: #c93e07;
}

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

.secondary-button:hover {
  border-color: var(--surface-strong);
  background: var(--brand-blue-soft);
  color: var(--surface-strong);
}

.danger-button {
  border-color: #c2410c;
  background: #fff7ed;
  color: #9a3412;
}

.form-message {
  margin: 0;
  color: #b91c1c;
  font-size: 14px;
}

.table-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: end;
  gap: 14px;
  margin: 18px 0 12px;
}

.table-toolbar label {
  width: min(360px, 100%);
}

.split-toolbar {
  justify-content: space-between;
}

.inline-check {
  display: flex;
  align-items: center;
  width: auto;
  min-height: 40px;
}

.inline-check input {
  width: 18px;
  min-height: 18px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}

table {
  width: 100%;
  min-width: 1680px;
  border-collapse: collapse;
}

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

th {
  background: #f4f7fb;
  color: #123d7d;
  font-size: 12px;
  text-transform: uppercase;
}

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

tbody tr:hover td {
  background: #f3f7fd;
}

.empty-table {
  color: var(--muted);
  text-align: center;
}

.life-status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.life-status-green {
  background: #dcfce7;
  color: #166534;
}

.life-status-yellow {
  background: #fef9c3;
  color: #854d0e;
}

.life-status-red {
  background: #fee2e2;
  color: #991b1b;
}

.life-status-muted {
  background: #e5e7eb;
  color: #4b5563;
}

.table-thumb {
  width: 68px;
  height: 46px;
  border: 1px solid var(--line);
  object-fit: cover;
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

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

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

  .dashboard-detail {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .main-content {
    padding: 18px 14px 24px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .user-session {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

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

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

  .nav-item {
    min-height: 42px;
    padding: 9px 10px;
    font-size: 13px;
  }

  h1 {
    font-size: 26px;
  }

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

  .chart-row {
    grid-template-columns: 1fr;
  }

  .chart-value {
    text-align: left;
  }
}
