/**
 * Gancao Admin — design tokens & layout
 * Direction: clinic ops console — deep teal ink, stone paper, organic brand type
 */

:root {
  --ink: #14201c;
  --ink-soft: #3a4a43;
  --teal: #1a5c57;
  --teal-deep: #0f3d3a;
  --sage: #6b8f71;
  --mist: #d5ddd6;
  --paper: #f0ede6;
  --paper-2: #e6e2d8;
  --surface: #faf8f4;
  --line: #c9cfc8;
  --accent: #b45309;
  --danger: #9b2c2c;
  --ok: #276749;
  --warn: #975a16;
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --radius: 10px;
  --font-brand: "Fraunces", "Songti SC", Georgia, serif;
  --font-ui: "Figtree", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "IBM Plex Mono", "Menlo", monospace;
  --shadow: 0 10px 30px rgba(20, 32, 28, 0.08);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--teal); }
a:hover { color: var(--teal-deep); text-decoration: none; }

/* ===== App shell ===== */
.app-shell {
  min-height: 100vh;
  display: flex;
}

.app-shell.is-auth {
  display: block;
}

.login-wrap {
  min-height: 100vh;
}

.content-login {
  padding: 0;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--teal-deep) 0%, #123532 55%, #0c2a28 100%);
  color: #e8f0ec;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 20;
  box-shadow: 4px 0 24px rgba(15, 61, 58, 0.25);
}

.sidebar-brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand .mark {
  font-family: var(--font-brand);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: #fff;
}

.sidebar-brand .mark em {
  font-style: italic;
  color: #b8d4c8;
  font-weight: 500;
}

.sidebar-brand .sub {
  margin-top: 6px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(232, 240, 236, 0.55);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 10px 20px;
}

.nav-section {
  margin: 14px 10px 8px;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(232, 240, 236, 0.4);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin: 2px 0;
  border-radius: 8px;
  color: rgba(232, 240, 236, 0.78);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.nav-link:hover,
.nav-link:focus {
  background: rgba(255,255,255,0.08);
  color: #fff;
  outline: none;
}

.nav-link.active {
  background: rgba(255,255,255,0.14);
  color: #fff;
  box-shadow: inset 3px 0 0 #c5e0d4;
}

.nav-link .glyphicon {
  width: 16px;
  opacity: 0.85;
  font-size: 12px;
}

.sidebar-foot {
  padding: 14px 16px 18px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12px;
  color: rgba(232, 240, 236, 0.5);
}

.main-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(107, 143, 113, 0.12), transparent 60%),
    radial-gradient(900px 400px at 100% 0%, rgba(26, 92, 87, 0.08), transparent 50%),
    var(--paper);
}

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: rgba(250, 248, 244, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-title {
  font-size: 14px;
  color: var(--ink-soft);
}

.topbar-title strong {
  color: var(--ink);
  font-weight: 600;
}

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

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--mist);
  color: var(--ink-soft);
  font-size: 12px;
}

.content {
  padding: 28px 32px 48px;
  flex: 1;
}

/* ===== Page chrome ===== */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.page-head h1 {
  margin: 0;
  font-family: var(--font-brand);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.page-head p {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
  max-width: 520px;
}

.page-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

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

.surface-pad { padding: 20px 22px; }

.section-label {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 12px;
}

/* ===== Buttons ===== */
.btn {
  border-radius: 8px;
  font-weight: 600;
  font-family: var(--font-ui);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--teal-deep);
  border-color: var(--teal-deep);
  color: #fff;
}

.btn-default {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.btn-default:hover {
  background: var(--paper-2);
  border-color: var(--sage);
}

.btn-success {
  background: var(--ok);
  border-color: var(--ok);
}

.btn-warning {
  background: var(--warn);
  border-color: var(--warn);
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
}

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
}

.btn-ghost:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

/* ===== Forms ===== */
.form-control {
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: none;
  height: 38px;
}

.form-control:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(26, 92, 87, 0.15);
}

textarea.form-control { height: auto; }

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

/* ===== Dashboard ===== */
.dash-hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

@media (max-width: 992px) {
  .dash-hero { grid-template-columns: 1fr; }
}

.dash-intro {
  padding: 28px 30px;
  background:
    linear-gradient(135deg, rgba(26, 92, 87, 0.92), rgba(15, 61, 58, 0.95)),
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  color: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  animation: rise-in 0.55s ease both;
}

.dash-intro h1 {
  font-family: var(--font-brand);
  font-size: 34px;
  margin: 0 0 10px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.dash-intro p {
  margin: 0;
  max-width: 420px;
  color: rgba(255,255,255,0.78);
  line-height: 1.55;
  font-size: 15px;
}

.dash-intro .hero-meta {
  margin-top: 22px;
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
}

.stat-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-tile {
  padding: 18px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  animation: rise-in 0.55s ease both;
}

.stat-tile:nth-child(2) { animation-delay: 0.06s; }
.stat-tile:nth-child(3) { animation-delay: 0.12s; }
.stat-tile:nth-child(4) { animation-delay: 0.18s; }

.stat-tile .label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.stat-tile .value {
  margin-top: 8px;
  font-family: var(--font-brand);
  font-size: 28px;
  font-weight: 600;
  color: var(--teal-deep);
  line-height: 1;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.module-card {
  display: block;
  padding: 20px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  color: inherit;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  animation: rise-in 0.5s ease both;
}

.module-card:hover {
  transform: translateY(-3px);
  border-color: var(--sage);
  box-shadow: var(--shadow);
  color: inherit;
}

.module-card .icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--mist);
  color: var(--teal);
  margin-bottom: 14px;
}

.module-card h3 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 700;
}

.module-card p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.45;
}

.module-card .go {
  margin-top: 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--teal);
  letter-spacing: 0.04em;
}

/* ===== Login ===== */
.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
}

@media (max-width: 900px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-visual { min-height: 220px; }
}

.login-visual {
  background:
    linear-gradient(160deg, rgba(15, 61, 58, 0.92), rgba(26, 92, 87, 0.75)),
    radial-gradient(circle at 30% 40%, rgba(184, 212, 200, 0.35), transparent 45%),
    linear-gradient(180deg, #0f3d3a, #1a5c57);
  color: #fff;
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.login-visual::after {
  content: "";
  position: absolute;
  inset: auto -20% -30% 20%;
  height: 70%;
  background: radial-gradient(ellipse, rgba(197, 224, 212, 0.2), transparent 70%);
  pointer-events: none;
  animation: drift 12s ease-in-out infinite alternate;
}

.login-visual .brand {
  font-family: var(--font-brand);
  font-size: 42px;
  font-weight: 600;
  letter-spacing: -0.03em;
  position: relative;
  z-index: 1;
  animation: rise-in 0.6s ease both;
}

.login-visual .brand span {
  display: block;
  margin-top: 8px;
  font-size: 15px;
  font-family: var(--font-ui);
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.6);
}

.login-visual .quote {
  position: relative;
  z-index: 1;
  max-width: 360px;
  font-size: 18px;
  line-height: 1.55;
  color: rgba(255,255,255,0.82);
  animation: rise-in 0.7s ease 0.1s both;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 28px;
  background:
    linear-gradient(180deg, rgba(240, 237, 230, 0.95), #e8e4da);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 32px 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  animation: rise-in 0.55s ease 0.05s both;
}

.login-card h2 {
  margin: 0 0 6px;
  font-family: var(--font-brand);
  font-size: 28px;
  font-weight: 600;
}

.login-card .lead {
  margin: 0 0 24px;
  color: var(--ink-soft);
  font-size: 14px;
}

.login-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  padding: 4px;
  background: var(--paper-2);
  border-radius: 10px;
}

.login-tabs button {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 8px 10px;
  border-radius: 8px;
  font-weight: 600;
  color: var(--ink-soft);
}

.login-tabs button.active {
  background: #fff;
  color: var(--teal-deep);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.alert {
  border-radius: 8px;
  border: none;
}

.alert-danger {
  background: #fde8e8;
  color: var(--danger);
}

.alert-info {
  background: #e7f0ea;
  color: var(--teal-deep);
}

/* ===== Feature pages ===== */
.toolbar-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 16px;
}

.toolbar-row .form-group {
  margin: 0;
  min-width: 180px;
}

.table-wrap {
  overflow: auto;
  border-radius: 0 0 var(--radius) var(--radius);
}

.table {
  margin: 0;
  background: #fff;
}

.table > thead > tr > th {
  background: #f3f1ea;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  white-space: nowrap;
}

.table > tbody > tr:hover { background: #f7f5ef; }

.list-pane {
  max-height: calc(100vh - 220px);
  overflow: auto;
}

.list-group-item {
  border-color: var(--line);
  cursor: pointer;
}

.list-group-item:hover,
.list-group-item.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.log-console {
  width: 100%;
  min-height: 420px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  background: #121a18;
  color: #c9e0d4;
  border: 1px solid #1e2e2a;
  border-radius: 8px;
  padding: 14px;
  resize: vertical;
}

.search-hit {
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #f3f1ea;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

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

.metric .k {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.metric .v {
  margin-top: 8px;
  font-family: var(--font-brand);
  font-size: 28px;
  font-weight: 600;
  color: var(--teal-deep);
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--ink-soft);
}

.empty-state h3 {
  margin: 0 0 8px;
  color: var(--ink);
  font-family: var(--font-brand);
}

.placeholder-banner {
  padding: 14px 16px;
  border-radius: 8px;
  background: #fff7ed;
  border: 1px solid #f6d7a8;
  color: var(--warn);
  margin-bottom: 16px;
  font-size: 13px;
}

.modal-backdrop-custom {
  position: fixed;
  inset: 0;
  background: rgba(20, 32, 28, 0.45);
  z-index: 1040;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-panel {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow: auto;
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.modal-panel .mh {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-panel .mb {
  padding: 18px;
}

.modal-panel .mf {
  padding: 12px 18px 18px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-soft);
}

.spinning {
  animation: spin 1s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes drift {
  from { transform: translateX(0); }
  to { transform: translateX(-40px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 18px 16px 36px; }
  .page-head h1 { font-size: 24px; }
}
