:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #152236;
  --muted: #64748b;
  --line: #dde5ef;
  --teal: #087d7f;
  --teal-dark: #044b55;
  --lime: #b6c51c;
  --amber: #f28c00;
  --gold: #d99a00;
  --red: #e5484d;
  --green: #15996b;
  --shadow: 0 12px 34px rgba(21, 34, 54, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
}

.login-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 520px) 1fr;
  gap: 36px;
  padding: 24px;
  overflow: hidden;
}

.login-panel {
  align-self: start;
  min-height: calc(100vh - 48px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 72px 46px 36px;
}

.brand-mark {
  width: 72px;
  height: 72px;
  margin: 0 auto 28px;
  color: var(--teal-dark);
}

.brand-mark svg,
.security-note svg,
.icon-button svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.login-panel h1 {
  margin: 0;
  text-align: center;
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: 0;
}

.login-panel p {
  margin: 10px 0 44px;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
}

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

.login-form label {
  margin-top: 4px;
  font-size: 15px;
  font-weight: 700;
}

.login-form input {
  width: 100%;
  height: 44px;
  border: 1px solid #cdd6e1;
  border-radius: 5px;
  padding: 0 14px;
  color: var(--text);
  background: #fff;
  outline: none;
}

.login-form input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 125, 127, 0.14);
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 48px;
}

.icon-button {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: #6c7989;
  cursor: pointer;
}

.primary-button,
.ghost-button {
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.primary-button {
  height: 48px;
  margin-top: 10px;
  color: #fff;
  background: linear-gradient(180deg, #075d67 0%, #043d47 100%);
  font-size: 16px;
  font-weight: 800;
  box-shadow: 0 10px 20px rgba(4, 75, 85, 0.22);
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 24px rgba(4, 75, 85, 0.25);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.72;
  transform: none;
}

.form-message {
  min-height: 20px;
  color: var(--red);
  font-size: 14px;
}

.security-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 28px;
  color: #7a8593;
  font-size: 14px;
}

.security-note svg {
  width: 18px;
  height: 18px;
}

.login-preview {
  position: relative;
  min-height: calc(100vh - 48px);
  padding: 58px 34px;
  filter: blur(2.2px);
  opacity: 0.55;
  pointer-events: none;
}

.preview-toolbar,
.preview-kpis span,
.preview-grid div {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.preview-toolbar {
  height: 54px;
  margin-bottom: 18px;
}

.preview-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.preview-kpis span {
  height: 104px;
}

.preview-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
}

.preview-grid div {
  min-height: 360px;
}

.dashboard-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 176px 1fr;
}

.sidebar {
  background: linear-gradient(180deg, #083248 0%, #0b2134 100%);
  color: #dbe8f0;
  padding: 28px 14px;
}

.sidebar-title {
  height: 44px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  margin-bottom: 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  font-weight: 800;
}

.sidebar nav {
  display: grid;
  gap: 7px;
}

.sidebar a {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  color: #dbe8f0;
  text-decoration: none;
  border-radius: 6px;
  font-size: 15px;
}

.sidebar a.active,
.sidebar a:hover {
  background: #07878a;
  color: #fff;
}

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

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

.topbar h1 {
  display: inline;
  margin: 0 28px 0 0;
  font-size: 24px;
  line-height: 1.2;
}

.topbar span {
  color: var(--text);
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 22px;
  color: var(--muted);
  font-size: 14px;
}

.ghost-button {
  min-width: 64px;
  height: 34px;
  background: transparent;
  color: var(--text);
}

.ghost-button:hover {
  background: #e8eef6;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0 14px;
}

.kpi,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(21, 34, 54, 0.05);
}

.kpi {
  min-height: 122px;
  padding: 20px 16px 14px 72px;
  position: relative;
}

.kpi-icon {
  position: absolute;
  left: 18px;
  top: 28px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 900;
}

.teal { background: var(--teal); }
.lime { background: var(--lime); }
.amber { background: var(--amber); }
.gold { background: var(--gold); }

.kpi p {
  margin: 0 0 8px;
  color: #334155;
  font-size: 14px;
  font-weight: 800;
}

.kpi strong {
  display: block;
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: 0;
}

.kpi small {
  display: block;
  margin-top: 12px;
  color: var(--green);
  font-size: 13px;
}

.kpi small.negative {
  color: var(--red);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.85fr);
  gap: 14px;
}

.panel {
  padding: 16px 18px;
  min-width: 0;
}

.chart-panel,
.exception-panel,
.account-panel,
.upload-panel,
.history-panel {
  grid-column: 1;
}

.ranking-panel,
.actions-panel {
  grid-column: 2;
}

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

.panel h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
}

.filters {
  display: flex;
  gap: 8px;
}

select {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 30px 0 10px;
  background: #fff;
  color: #334155;
  font-size: 13px;
}

.line-chart {
  min-height: 276px;
  border-top: 1px solid #eef2f6;
}

.line-chart svg {
  display: block;
  width: 100%;
  height: 276px;
}

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

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid #edf1f5;
  text-align: left;
  white-space: nowrap;
}

th {
  color: #526071;
  background: var(--surface-soft);
  font-weight: 800;
}

td.numeric,
th.numeric {
  text-align: right;
}

.delta-up {
  color: var(--green);
  font-weight: 700;
}

.delta-down {
  color: var(--red);
  font-weight: 700;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 800;
}

.status.pending {
  color: #b86b00;
  background: #fff2d6;
}

.status.processing {
  color: #126ea6;
  background: #e0f2fe;
}

.status.done {
  color: #15815d;
  background: #dcfce7;
}

.insight-list {
  margin: 0;
  padding-left: 18px;
  color: #334155;
  line-height: 1.8;
}

.account-panel {
  grid-column: 1 / -1;
}

.upload-panel,
.history-panel {
  grid-column: 1 / -1;
}

.admin-tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 5px;
  color: #075d67;
  background: #e6f4f1;
  font-size: 13px;
  font-weight: 800;
}

.account-form,
.upload-form {
  display: grid;
  grid-template-columns: 1fr 1fr 160px auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  margin-bottom: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.account-form label,
.upload-form label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.account-form input,
.account-form select,
.upload-form input {
  width: 100%;
  height: 38px;
  border: 1px solid #cdd6e1;
  border-radius: 5px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
}

.account-actions {
  display: flex;
  gap: 8px;
}

.upload-form {
  grid-template-columns: 1fr 220px 1fr auto;
}

.file-field input {
  padding: 7px 12px;
}

.upload-actions {
  display: flex;
  align-items: end;
}

.primary-button.compact,
.ghost-button.bordered {
  height: 38px;
  min-width: 88px;
  margin: 0;
  font-size: 14px;
}

.ghost-button.bordered {
  border: 1px solid var(--line);
  background: #fff;
}

.account-form .form-message,
.upload-form .form-message {
  grid-column: 1 / -1;
}

.muted-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.history-title-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 15px;
  font-weight: 900;
  text-align: left;
}

.history-title-button:hover {
  color: var(--teal);
}

.history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
}

.history-item.active {
  border-color: rgba(8, 125, 127, 0.45);
  background: #edf8f7;
}

.link-button,
.danger-button {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.link-button {
  color: #126ea6;
}

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

@media (max-width: 1100px) {
  .login-view {
    grid-template-columns: 1fr;
  }

  .login-preview {
    display: none;
  }

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

  .sidebar {
    display: none;
  }

  .kpi-row {
    grid-template-columns: repeat(3, 1fr);
  }

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

  .chart-panel,
  .exception-panel,
  .ranking-panel,
  .actions-panel,
  .account-panel,
  .upload-panel,
  .history-panel {
    grid-column: auto;
  }

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

@media (max-width: 720px) {
  .login-view {
    padding: 14px;
  }

  .login-panel {
    min-height: auto;
    padding: 42px 22px 28px;
  }

  .workspace {
    padding: 16px;
  }

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

  .topbar h1 {
    display: block;
    margin: 0 0 6px;
  }

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

  .kpi {
    min-height: 104px;
  }

  .panel {
    overflow-x: auto;
  }

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

  .account-actions,
  .upload-actions {
    flex-wrap: wrap;
  }

  .history-item {
    grid-template-columns: 1fr;
  }
}
