/* ============================================================
   Labkeep — Instrument Booking prototype
   Aesthetic: "Soft Lab" — warm cream, sage-teal, clay accents.
   Display: Fraunces (serif) · Body: Hanken Grotesk
   ============================================================ */

:root {
  /* warm neutral surfaces */
  --bg:        #F4EEE2;
  --bg-tint:   #EDE5D5;
  --surface:   #FFFCF6;
  --surface-2: #FAF5EB;
  --line:      #E7DECB;
  --line-soft: #F0E9DA;

  /* warm ink */
  --ink:       #2C2823;
  --ink-soft:  #6E665A;
  --ink-faint: #A39A89;

  /* sage-teal primary */
  --primary:      #3F7E74;
  --primary-deep: #2F5F57;
  --primary-soft: #D9E8E2;
  --primary-tint: #ECF3F0;

  /* clay = booked */
  --clay:      #CF8A63;
  --clay-deep: #B06E48;
  --clay-soft: #F4E1D3;

  /* red = 拖选中的区间（区别于 today 的绿环） */
  --sel:       #C24A3E;
  --sel-soft:  #F8E1DC;

  /* maintenance = warm gray */
  --maint:      #A89F8E;
  --maint-soft: #E9E3D6;

  --radius:    18px;
  --radius-sm: 12px;
  --shadow:    0 1px 2px rgba(44,40,35,.05), 0 16px 32px -20px rgba(44,40,35,.28);
  --shadow-sm: 0 1px 2px rgba(44,40,35,.05), 0 8px 18px -14px rgba(44,40,35,.22);
  --ease: cubic-bezier(.2, .7, .25, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

html, body { height: 100%; }

body {
  font-family: "Hanken Grotesk", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* grain + soft sage glow atmosphere */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  background:
    radial-gradient(120% 80% at 92% -10%, rgba(63,126,116,.14), transparent 55%),
    radial-gradient(90% 70% at -8% 108%, rgba(207,138,99,.10), transparent 55%);
}
body::after {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0; opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.045'/%3E%3C/svg%3E");
}

h1, h2, h3 { font-family: "Fraunces", Georgia, serif; font-weight: 500; letter-spacing: -.01em; }

button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ============ brand ============ */
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  font-size: 22px; color: var(--primary);
  line-height: 1; transform: translateY(1px);
}
.brand-name {
  font-family: "Fraunces", serif; font-weight: 600;
  font-size: 20px; letter-spacing: -.02em; color: var(--ink);
}

/* ============ buttons ============ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 9px 16px; font-size: 14px; font-weight: 600;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary {
  background: var(--primary); color: #fff;
  box-shadow: 0 6px 16px -8px rgba(47,95,87,.7);
}
.btn-primary:hover { background: var(--primary-deep); box-shadow: 0 10px 22px -8px rgba(47,95,87,.65); transform: translateY(-1px); }
.btn-ghost {
  background: var(--surface); color: var(--ink-soft);
  border-color: var(--line);
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-block { width: 100%; justify-content: center; padding: 12px; }
.btn-mini { padding: 5px 11px; font-size: 13px; border-radius: 9px; }

/* ============ fields ============ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); letter-spacing: .01em; }
.field input, .field select {
  font-family: inherit; font-size: 14.5px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 12px;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ============ LOGIN ============ */
.login-screen {
  position: relative; z-index: 1;
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.login-atmosphere {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(60% 50% at 20% 20%, rgba(63,126,116,.16), transparent 60%),
    radial-gradient(55% 45% at 85% 80%, rgba(207,138,99,.14), transparent 60%);
}
.login-card {
  width: 100%; max-width: 410px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 26px; box-shadow: var(--shadow);
  padding: 38px 38px 28px;
  animation: rise .7s var(--ease) both;
}
.login-title {
  font-size: 38px; line-height: 1.02; margin: 22px 0 10px;
  letter-spacing: -.025em;
}
.login-sub { color: var(--ink-soft); margin-bottom: 26px; }
.login-form { display: flex; flex-direction: column; gap: 15px; }
.login-form .btn { margin-top: 6px; }
.login-foot { margin-top: 20px; font-size: 12.5px; color: var(--ink-faint); text-align: center; }

/* ============ APP SHELL ============ */
.app-shell {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 244px 1fr;
  min-height: 100vh;
}

/* sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  display: flex; flex-direction: column; gap: 26px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { padding: 4px 8px 0; }
.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  width: 100%; text-align: left; border: none; background: none;
  padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 14.5px; font-weight: 600; color: var(--ink-soft);
  transition: background .15s, color .15s;
}
.nav-ico { font-size: 15px; width: 18px; text-align: center; color: var(--ink-faint); transition: color .15s; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--primary-tint); color: var(--primary-deep); }
.nav-item.active .nav-ico { color: var(--primary); }
.nav-group { margin-top: 14px; display: flex; flex-direction: column; gap: 3px; }
.nav-group-label {
  font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-faint); padding: 4px 12px 6px;
}

.sidebar-user {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 10px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line-soft);
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
}
.user-meta { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: 14px; }
.role-pill {
  font-size: 11px; font-weight: 700; color: var(--primary-deep);
  background: var(--primary-soft); padding: 1px 8px; border-radius: 99px; align-self: flex-start;
}
.role-toggle {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-faint);
  width: 28px; height: 28px; border-radius: 8px; font-size: 13px; flex-shrink: 0;
  transition: color .15s, border-color .15s;
}
.role-toggle:hover { color: var(--primary); border-color: var(--primary); }

/* main */
.main-wrap { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 24px 36px; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 5;
}
.page-title { font-size: 26px; letter-spacing: -.02em; }
.page-date { color: var(--ink-faint); font-size: 13.5px; margin-top: 2px; }
.content { padding: 28px 36px 56px; display: flex; flex-direction: column; gap: 22px; }
.content > section { display: flex; flex-direction: column; gap: 22px; animation: rise .5s var(--ease) both; }

/* ============ panels & cards ============ */
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 22px;
}
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 18px;
}
.panel-title { font-size: 18px; }
.panel-sub { color: var(--ink-faint); font-size: 13px; margin-top: 3px; }
.cal-title { display: flex; align-items: center; gap: 10px; }
.cal-nav {
  width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2);
  color: var(--ink-soft); text-decoration: none; font-size: 16px; line-height: 1;
}
.cal-nav:hover { color: var(--primary-deep); border-color: var(--primary); background: var(--primary-tint); }
.cal-today-link { font-size: 12.5px; color: var(--primary); text-decoration: none; margin-left: 4px; }
.cal-today-link:hover { text-decoration: underline; }

.legend { display: flex; gap: 16px; align-items: center; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-soft); }
.dot { width: 11px; height: 11px; border-radius: 4px; display: inline-block; }
.dot-avail { background: var(--primary-soft); border: 1px solid var(--primary); }
.dot-booked { background: var(--clay); }
.dot-maint  { background: var(--maint); }
.dot-mine   { background: var(--primary-soft); border: 2px solid var(--primary); }

/* ============ stat cards ============ */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 18px 20px; position: relative; overflow: hidden;
}
.stat-card::after {
  content: ""; position: absolute; right: -18px; top: -18px;
  width: 70px; height: 70px; border-radius: 50%; opacity: .5;
  background: var(--accent, var(--primary-soft));
}
.stat-num { font-family: "Fraunces", serif; font-size: 40px; font-weight: 500; line-height: 1; letter-spacing: -.03em; }
.stat-label { color: var(--ink-soft); font-size: 13px; margin-top: 7px; font-weight: 500; }
.stat-card.is-busy  { --accent: var(--clay-soft); }
.stat-card.is-busy  .stat-num { color: var(--clay-deep); }
.stat-card.is-free  .stat-num { color: var(--primary); }
.stat-card.is-maint { --accent: var(--maint-soft); }
.stat-card.is-maint .stat-num { color: var(--maint); }
.stat-card.is-mine  .stat-num { color: var(--ink); }

/* ============ timeline (7-day grid) ============ */
.timeline { display: flex; flex-direction: column; gap: 7px; }
.tl-head, .tl-row {
  display: grid; grid-template-columns: 190px 1fr; align-items: center;
}
.tl-head { margin-bottom: 4px; }
.tl-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.tl-day-h { text-align: center; padding: 4px 0; }
.tl-day-h .wd { font-size: 11.5px; color: var(--ink-faint); font-weight: 600; }
.tl-day-h .dn { font-family: "Fraunces", serif; font-size: 16px; color: var(--ink); }
.tl-day-h.today .dn {
  background: var(--primary); color: #fff; border-radius: 9px;
  width: 26px; height: 26px; line-height: 26px; display: inline-block; margin-top: 1px;
}

.tl-label {
  font-weight: 600; font-size: 13.5px; padding-right: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer; transition: color .15s;
}
.tl-label:hover { color: var(--primary); }
.tl-label small { display: block; font-weight: 500; font-size: 11.5px; color: var(--ink-faint); }

.tl-track {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
  position: relative;
}
.tl-cell {
  grid-row: 1; height: 46px; border-radius: 10px;
  background: var(--primary-tint);
  border: 1px dashed color-mix(in srgb, var(--primary) 28%, transparent);
}
.tl-cell.maint {
  background: repeating-linear-gradient(45deg, var(--maint-soft), var(--maint-soft) 6px, #f1ecdf 6px, #f1ecdf 12px);
  border: 1px solid var(--line);
}
.tl-bar {
  grid-row: 1; z-index: 1; margin: 0 1px;
  background: var(--clay); color: #fff;
  border-radius: 10px; padding: 0 12px;
  display: flex; flex-direction: column; justify-content: center;
  box-shadow: 0 6px 14px -8px rgba(176,110,72,.8);
  cursor: default; overflow: hidden;
}
.tl-bar.mine { background: var(--primary); box-shadow: 0 6px 14px -8px rgba(47,95,87,.8); }
.tl-bar .who { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-bar .what { font-size: 11px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============ booking list ============ */
.booking-list { display: flex; flex-direction: column; gap: 10px; }
.bk-row {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 16px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--line-soft);
}
.bk-swatch { width: 4px; align-self: stretch; border-radius: 99px; background: var(--primary); }
.bk-main { flex: 1; min-width: 0; }
.bk-inst { font-weight: 700; font-size: 14.5px; }
.bk-purpose { color: var(--ink-soft); font-size: 13px; }
.bk-dates {
  font-family: "Fraunces", serif; font-size: 14px; color: var(--primary-deep);
  background: var(--primary-tint); padding: 3px 11px; border-radius: 99px; white-space: nowrap;
}
.bk-actions { display: flex; gap: 7px; }

/* ============ instrument cards ============ */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.inst-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 20px; cursor: pointer;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s;
}
.inst-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--primary) 40%, var(--line)); }
.inst-card-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.inst-glyph {
  width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center;
  background: var(--primary-tint); color: var(--primary); font-size: 21px;
}
.inst-name { font-family: "Fraunces", serif; font-size: 18.5px; font-weight: 500; }
.inst-cat { color: var(--ink-faint); font-size: 13px; margin-top: 2px; }
.inst-meta { display: flex; flex-direction: column; gap: 5px; margin: 14px 0; font-size: 13px; color: var(--ink-soft); }
.inst-meta span { display: flex; gap: 7px; }
.inst-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.inst-foot .upcoming { font-size: 12.5px; color: var(--ink-faint); }

.status-pill { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 99px; }
.status-active { color: var(--primary-deep); background: var(--primary-soft); }
.status-maint  { color: #8a7a5a; background: var(--maint-soft); }

/* ============ detail head ============ */
.back-link { background: none; border: none; color: var(--ink-soft); font-weight: 600; font-size: 14px; padding: 0; }
.back-link:hover { color: var(--primary); }
.detail-head {
  display: flex; align-items: center; gap: 18px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 22px;
}
.detail-head .inst-glyph { width: 56px; height: 56px; font-size: 26px; }
.detail-head h3 { font-size: 24px; }
.detail-head .dh-meta { color: var(--ink-soft); font-size: 13.5px; margin-top: 4px; display: flex; gap: 14px; }

/* ============ calendar ============ */
.cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin-bottom: 8px;
}
.cal-weekdays span { text-align: center; font-size: 12px; font-weight: 700; color: var(--ink-faint); letter-spacing: .05em; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.cal-day {
  min-height: 84px; border-radius: 12px; padding: 8px 9px;
  background: var(--primary-tint); border: 1px solid transparent;
  display: flex; flex-direction: column; gap: 5px;
  transition: transform .15s, box-shadow .15s;
}
.cal-day.empty { background: transparent; }
.cal-day .cd-num { font-family: "Fraunces", serif; font-size: 15px; color: var(--ink-soft); }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--primary); }
.cal-day.today .cd-num { color: var(--primary-deep); font-weight: 600; }
.cal-day.avail { cursor: pointer; }
.cal-day.avail:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); border-color: var(--primary); }
.cal-day.past { background: var(--surface-2); opacity: .55; }
.cal-day.booked { background: var(--clay-soft); }
.cal-day.booked .cd-num { color: var(--clay-deep); }
.cal-day.mine { background: var(--primary-soft); border: 2px solid var(--primary); }
.cal-tag {
  font-size: 11px; font-weight: 600; line-height: 1.3;
  background: rgba(255,255,255,.6); border-radius: 7px; padding: 3px 6px;
  color: var(--clay-deep); margin-top: auto;
}
.cal-day.mine .cal-tag { color: var(--primary-deep); background: rgba(255,255,255,.7); }
/* 拖选中的预约区间——用红色，与 today 的绿环明显区分 */
.cal-day.sel { background: var(--sel-soft); box-shadow: inset 0 0 0 2px var(--sel); }
.cal-day.sel .cd-num { color: var(--sel); font-weight: 600; }
.cal.dragging { user-select: none; }

/* ============ tables ============ */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; font-size: 12px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-faint);
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.data-table td { padding: 13px 14px; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.data-table tr:last-child td { border-bottom: none; }
.data-table .u-name { font-weight: 600; }
.data-table .u-sub { color: var(--ink-faint); font-size: 12.5px; }

/* ============ modal ============ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(44,40,35,.34); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 24px;
  animation: fade .2s ease both;
}
.modal {
  width: 100%; max-width: 460px; position: relative;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 22px; box-shadow: var(--shadow); padding: 28px;
  animation: rise .35s var(--ease) both;
}
.modal-close {
  position: absolute; top: 18px; right: 18px;
  border: none; background: var(--surface-2); color: var(--ink-soft);
  width: 30px; height: 30px; border-radius: 9px; font-size: 13px;
}
.modal-close:hover { background: var(--clay-soft); color: var(--clay-deep); }
.modal-title { font-size: 22px; }
.modal-sub { color: var(--ink-faint); font-size: 13px; margin: 4px 0 20px; }
#booking-form { display: flex; flex-direction: column; gap: 15px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

.conflict-banner {
  font-size: 13px; font-weight: 600; padding: 11px 14px; border-radius: var(--radius-sm);
}
.conflict-banner.ok   { background: var(--primary-soft); color: var(--primary-deep); }
.conflict-banner.bad  { background: var(--clay-soft); color: var(--clay-deep); }

/* ============ animations ============ */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.content > section > * { animation: rise .5s var(--ease) both; }
.content > section > *:nth-child(2) { animation-delay: .05s; }
.content > section > *:nth-child(3) { animation-delay: .1s; }

/* ============ responsive ============ */
@media (max-width: 920px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-group { flex-direction: row; margin-top: 0; }
  .nav-group-label { display: none; }
  .sidebar-user { margin-left: auto; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .tl-head, .tl-row { grid-template-columns: 120px 1fr; }
  .content, .topbar { padding-left: 18px; padding-right: 18px; }
}
