:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #1f2933;
  --muted: #64748b;
  --line: #d8dee6;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --accent: #b45309;
  --danger: #b42318;
  --shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

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

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

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 264px 1fr;
  overflow: hidden;
}

.sidebar {
  background: #17212b;
  color: #ecf3f1;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px;
}

.brand-logo-wrap {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
  flex: 0 0 auto;
}

.brand-logo-wrap img {
  display: block;
  width: 48px;
  height: auto;
}

.brand strong,
.brand small { display: block; }

.brand small,
.sidebar-note span {
  color: #a7b7c4;
  font-size: 0.82rem;
}

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

.nav a {
  color: #cbd5df;
  padding: 8px 10px;
  border-radius: 8px;
  font-weight: 650;
  font-size: 0.92rem;
  line-height: 1.15;
}

.nav a:hover,
.nav a.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.nav-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.nav-section > span {
  color: #8295a6;
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
  padding: 0 2px 3px;
  grid-column: 1 / -1;
}

.sidebar-note {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 6px;
}

.sidebar-note form { margin: 4px 0 0; }

.sidebar-logout {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  min-height: 36px;
  border-radius: 8px;
  font-weight: 750;
  cursor: pointer;
}

.sidebar-logout:hover { background: rgba(255, 255, 255, 0.14); }

.main {
  height: 100vh;
  overflow-y: auto;
  padding: 28px;
  min-width: 0;
}

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

.topbar h1,
.panel h2,
.update-box h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 1.75rem;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 800;
}

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

.button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
  min-height: 40px;
  border-radius: 8px;
  font-weight: 750;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.button.primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.button.primary:hover { background: var(--primary-dark); }
.button.ghost { background: transparent; }
.button.small { min-height: 34px; padding: 7px 10px; font-size: 0.9rem; }

.flash-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.flash {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.flash.success {
  border-color: #99d8ce;
  background: #e8f7f4;
}

.flash.error {
  border-color: #f1aaa2;
  background: #fff0ee;
}

.login-page {
  min-height: 100vh;
  background: var(--bg);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(90deg, #17212b 0, #17212b 50%, transparent 50%),
    var(--bg);
}

.login-panel {
  width: min(100%, 860px);
  min-height: 510px;
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(360px, 1.05fr);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.login-intro {
  background: #17212b;
  color: #ecf3f1;
  padding: 34px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
}

.login-intro img {
  width: 92px;
  max-width: 42%;
  height: auto;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px;
}

.login-intro .eyebrow {
  color: #a7b7c4;
}

.login-intro h1 {
  margin: 0;
  font-size: 2.25rem;
  line-height: 1.05;
}

.login-card {
  padding: 42px;
  display: grid;
  align-content: center;
  gap: 20px;
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.login-brand img {
  width: 54px;
  height: auto;
}

.login-card h2 {
  margin: 0;
  font-size: 1.75rem;
  line-height: 1.1;
}

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

.login-form label {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-weight: 750;
}

.login-form input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  background: #ffffff;
}

.login-form input:focus {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  border-color: var(--primary);
}

.password-field {
  position: relative;
  display: block;
}

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

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transform: translateY(-50%);
}

.password-toggle:hover {
  color: var(--primary);
  background: rgba(15, 118, 110, 0.08);
}

.password-toggle:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.18);
}

.password-icon {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.password-toggle .password-icon-hide {
  display: none;
}

.password-toggle.is-visible .password-icon-show {
  display: none;
}

.password-toggle.is-visible .password-icon-hide {
  display: block;
}

.login-actions {
  display: flex;
  justify-content: flex-end;
}

.login-actions .button {
  min-width: 128px;
}

.login-remember {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: 0.9rem;
}

.welcome-dialog {
  width: min(92vw, 480px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 26px 80px rgba(15, 23, 42, 0.32);
}

.welcome-dialog::backdrop {
  background: rgba(15, 23, 42, 0.58);
}

.welcome-dialog-body {
  padding: 30px;
  display: grid;
  gap: 12px;
  justify-items: start;
  background: #ffffff;
}

.welcome-dialog-body img {
  width: 82px;
  height: auto;
}

.welcome-dialog-body h2 {
  margin: 0;
  font-size: 1.8rem;
}

.welcome-dialog-body p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.welcome-dialog-body .button {
  margin-top: 8px;
  min-width: 130px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

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

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

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

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 18px;
}

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

.panel { padding: 18px; }
.form-panel { padding: 22px; max-width: 980px; }

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

.panel-header.secondary {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

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

.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 8px;
  padding: 12px;
}

.list-row strong,
.list-row small,
.project-card span,
.project-card small,
.credential-card span,
.credential-card small {
  display: block;
}

.list-row small,
.project-card small,
.credential-card small,
.client {
  color: var(--muted);
  margin-top: 4px;
}

.pill {
  white-space: nowrap;
  border-radius: 999px;
  background: #e2f2ef;
  color: #0f766e;
  padding: 5px 9px;
  font-weight: 800;
  font-size: 0.82rem;
}

.pill.vip,
.vip-label {
  background: #fff4d6;
  color: #9a6700;
  border: 1px solid #f2d27a;
}

.toolbar {
  justify-content: space-between;
  margin-bottom: 16px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  flex: 1;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 42px;
  font: inherit;
  color: var(--text);
}

textarea { resize: vertical; line-height: 1.45; }

.filters input[type="search"] { max-width: 420px; min-width: 260px; }
.filters select,
.filters input[type="month"] { max-width: 230px; }

.kanban {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.kanban-column {
  background: #e9eef3;
  border: 1px solid #d5dde6;
  border-radius: 8px;
  min-height: 360px;
  padding: 12px;
}

.kanban-title {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 0.92rem;
}

.kanban-title span {
  background: #fff;
  border-radius: 999px;
  min-width: 26px;
  text-align: center;
  font-weight: 800;
}

.project-card,
.credential-card {
  display: grid;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  margin-bottom: 10px;
}

.contact-card strong {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.vip-contact {
  border-color: #eccb68;
  background: linear-gradient(180deg, #ffffff, #fffaf0);
}

.vip-label {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 850;
}

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

.support-card {
  min-width: 0;
}

.support-card-button {
  width: 100%;
  min-height: 188px;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  gap: 7px;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 14px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.support-card-button:hover {
  border-color: #93b7b2;
}

.support-card-button strong,
.support-card-button small,
.support-card-description {
  display: block;
}

.support-card-button strong {
  line-height: 1.25;
}

.support-card-description {
  color: var(--muted);
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.project-card:hover,
.credential-card:hover,
.list-row:hover {
  border-color: #93b7b2;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  border-top: 1px solid var(--line);
  padding-top: 9px;
}

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

.form-grid.tight { gap: 12px; }

.phone-grid {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 10px;
}

.checkbox-label {
  align-self: end;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-soft);
  color: var(--text);
}

.checkbox-label input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  padding: 0;
  flex: 0 0 auto;
}

.checkbox-label span {
  font-weight: 850;
}

label {
  color: var(--muted);
  font-weight: 800;
  font-size: 0.86rem;
  display: grid;
  gap: 7px;
}

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

.form-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 18px;
  align-items: start;
}

.detail-layout.single { grid-template-columns: minmax(0, 900px); }

.meta-grid,
.secret-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

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

.meta-grid span,
.secret-grid div {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-width: 0;
}

.meta-grid strong,
.secret-grid strong {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.secret-grid span,
.secret-grid code {
  overflow-wrap: anywhere;
}

.description {
  white-space: pre-wrap;
  line-height: 1.55;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 4px;
}

.update-box {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 14px;
}

.timeline {
  display: grid;
  gap: 12px;
}

.ticket-dialog {
  width: min(960px, calc(100vw - 34px));
  max-height: min(820px, calc(100vh - 34px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

.ticket-dialog::backdrop {
  background: rgba(15, 23, 42, 0.62);
}

.modal-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.32);
  padding: 20px;
  max-height: inherit;
  overflow: auto;
}

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

.modal-header h2,
.modal-history h3 {
  margin: 0;
  letter-spacing: 0;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

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

.modal-history {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 14px;
}

.relation-list {
  gap: 10px;
}

.relation-list > strong {
  margin-top: 8px;
}

.relation-list > strong:first-child {
  margin-top: 0;
}

.timeline-item {
  border-left: 3px solid var(--primary);
  padding: 2px 0 2px 12px;
}

.timeline-item small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.timeline-item p {
  white-space: pre-wrap;
  margin: 8px 0 0;
  line-height: 1.45;
}

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

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

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

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

td a {
  color: var(--primary-dark);
  font-weight: 800;
}

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

.empty,
.empty-cell {
  color: var(--muted);
  margin: 0;
}

.empty.compact {
  font-size: 0.9rem;
  padding: 8px;
}

@media (max-width: 1120px) {
  .login-shell {
    background: var(--bg);
  }
  .login-panel {
    width: min(100%, 520px);
    min-height: 0;
    grid-template-columns: 1fr;
  }
  .login-intro {
    padding: 24px;
    flex-direction: row;
    align-items: center;
  }
  .login-intro img {
    width: 76px;
  }
  .login-intro h1 {
    font-size: 1.8rem;
  }
  .login-card {
    padding: 30px;
  }
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .sidebar {
    position: sticky;
    z-index: 20;
    height: auto;
    padding: 12px 16px;
    gap: 12px;
  }
  .brand-logo-wrap {
    width: 44px;
    height: 44px;
  }
  .brand-logo-wrap img { width: 40px; }
  .module-nav {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }
  .nav-section {
    min-width: 166px;
    align-content: start;
  }
  .sidebar-note { display: none; }
  .main {
    height: auto;
    min-height: 0;
    padding: 22px;
  }
  .metric-grid,
  .credential-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split,
  .detail-layout { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: repeat(5, 240px); }
}

@media (max-width: 720px) {
  .login-shell {
    padding: 16px;
    align-items: start;
  }
  .login-panel {
    margin-top: 18px;
  }
  .login-intro {
    padding: 20px;
  }
  .login-intro img {
    width: 64px;
  }
  .login-intro h1 {
    font-size: 1.5rem;
  }
  .login-card {
    padding: 22px;
  }
  .login-card h2 {
    font-size: 1.45rem;
  }
  .login-actions,
  .login-actions .button {
    width: 100%;
  }
  .sidebar { padding: 10px 12px; }
  .brand {
    padding: 4px;
    gap: 10px;
  }
  .brand strong { font-size: 0.95rem; }
  .brand small { font-size: 0.76rem; }
  .module-nav {
    margin: 0 -12px;
    padding: 0 12px 6px;
  }
  .nav-section {
    min-width: 142px;
    padding: 8px;
  }
  .nav a {
    padding: 8px;
    font-size: 0.86rem;
  }
  .main { padding: 16px; }
  .topbar { display: grid; }
  .topbar h1 { font-size: 1.45rem; }
  .topbar-actions { width: 100%; }
  .topbar-actions .button { flex: 1; }
  .support-card-grid { grid-template-columns: 1fr; }
  .metric-grid,
  .compact-grid,
  .credential-grid,
  .form-grid,
  .phone-grid,
  .meta-grid,
  .secret-grid,
  .modal-meta { grid-template-columns: 1fr; }
  .filters input[type="search"],
  .filters select,
  .filters input[type="month"],
  .filters .button { max-width: none; width: 100%; }
  .toolbar { align-items: stretch; }
  .toolbar > .button { width: 100%; }
}
