:root {
  --ink: #1c2430;
  --muted: #5c6775;
  --paper: #f3f0ea;
  --card: #ffffff;
  --line: #e3ddd3;
  --brand: #1f6b4a;
  --brand-dark: #154832;
  --taken: #0f6b34;
  --taken-bg: #e5f6ea;
  --free: #b42318;
  --free-bg: #fdeceb;
  --shadow: 0 1px 2px rgba(28, 36, 48, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

a { color: var(--brand-dark); }

h1, h2, h3 {
  letter-spacing: -0.02em;
  font-weight: 700;
}

h1 { font-size: 1.7rem; margin-bottom: 0.4rem; }

.app-nav {
  background: var(--brand-dark);
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}

.app-nav .navbar-toggler { border-color: rgba(255, 255, 255, 0.35); }
.app-nav .navbar-toggler-icon { filter: invert(1); }

.app-nav .navbar-brand,
.app-nav .nav-link,
.app-nav .btn-nav {
  color: #f4f7f5;
}

.app-nav .nav-link {
  border-radius: 8px;
  padding: 0.35rem 0.7rem;
}

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

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  margin-right: 0.35rem;
  border-radius: 8px;
  background: #e7f6ec;
  color: var(--brand-dark);
  font-weight: 700;
}

.whoami {
  color: rgba(255, 255, 255, 0.86);
  font-weight: 600;
}

.app-nav .btn-outline-light {
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
}

.app-nav .btn-outline-light:hover {
  background: #fff;
  color: var(--brand-dark);
}

.ghost-bar {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  align-items: center;
  flex-wrap: wrap;
  background: #fff6d8;
  color: #6a4b00;
  border-bottom: 1px solid #ead48a;
  padding: 0.65rem 1.25rem;
}

.app-main {
  width: min(1760px, calc(100% - 1.5rem));
  margin: 0 auto;
  padding: 1.25rem 0 3rem;
}

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

.btn { border-radius: 8px; }

.page-lead {
  color: var(--muted);
  margin-bottom: 1rem;
}

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.8rem 0 1rem;
}

.stat-pill {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.92rem;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 1rem;
}

.legend i {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 3px;
  margin-right: 0.3rem;
}

.legend .dot-tech { background: #1f6b4a; }
.legend .dot-vol { background: #1d4e89; }
.legend .dot-mine { background: #143024; box-shadow: inset 0 0 0 2px #fff, 0 0 0 1.5px #143024; }
.legend .dot-free { background: var(--free-bg); box-shadow: inset 0 0 0 1.5px var(--free); }

.month-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 1.1rem;
  box-shadow: var(--shadow);
}

.month-card h2 {
  font-size: 1.15rem;
  margin: 0;
  padding: 0.7rem 0.95rem;
  background: #faf8f4;
  border-bottom: 1px solid var(--line);
}

.phone-plan h2.month-title {
  font-size: 1.35rem;
  letter-spacing: -0.01em;
  color: #fff;
  background: #143024;
  border-bottom: 0;
  padding: 0.85rem 0.95rem;
}

.pc-plan { display: none; }

.week-block {
  margin: 0.7rem 0.65rem 0.15rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}

.month-card.phone-plan { padding-bottom: 0.7rem; background: #f7f4ee; }

.week-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  background: #1f6b4a;
  color: #fff;
}

.week-kw {
  font-weight: 800;
  letter-spacing: 0.03em;
  font-size: 0.95rem;
}

.week-range {
  font-size: 0.84rem;
  text-align: right;
}

.day-card {
  padding: 0.8rem 0.75rem 0.7rem;
  border-top: 1px solid var(--line);
  background: #fff;
}

.day-card.weekend { background: #fbf6ee; }
.day-card.is-today {
  background: #eef8f2;
  box-shadow: inset 4px 0 0 var(--brand);
}

.day-head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.day-name {
  font-weight: 800;
  font-size: 1.08rem;
}

.today-pill {
  margin-left: auto;
  background: var(--brand);
  color: #fff;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
}

.cal-num {
  display: inline-flex;
  min-width: 2.45rem;
  height: 2.45rem;
  padding: 0 0.45rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #efeae2;
  font-weight: 800;
  font-size: 1.15rem;
}

.day-card.is-today .cal-num {
  background: var(--brand);
  color: #fff;
}

.slot-row {
  display: grid;
  grid-template-columns: 3.4rem 1fr;
  gap: 0.45rem;
  margin-top: 0.55rem;
  align-items: start;
}

.slot-time {
  font-weight: 700;
  color: var(--muted);
  padding-top: 0.7rem;
  font-variant-numeric: tabular-nums;
}

.slot-teams {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.4rem;
}

.team-line {
  display: grid;
  grid-template-columns: 6.4rem 1fr;
  gap: 0.4rem;
  align-items: stretch;
}

.team-tag {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.35rem 0.3rem;
  text-align: center;
}

.team-tag.team { background: #e5f6ea; color: #0f6b34; }
.team-tag.user { background: #e7f0fb; color: #1d4e89; }

.person-line {
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
  min-width: 0;
}

.person-line .chip { flex: 1 1 auto; min-width: 0; }

.tel-link {
  flex: 0 0 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid #1f6b4a;
  background: #fff;
  color: #1f6b4a;
  text-decoration: none;
}

.tel-icon {
  width: 1.15rem;
  height: 1.15rem;
  display: block;
}

.chip {
  display: flex;
  align-items: center;
  min-height: 44px;
  border-radius: 10px;
  padding: 0.4rem 0.75rem;
  font-size: 1rem;
  line-height: 1.25;
  text-align: left;
}

.chip.taken.team {
  background: #d8f3e2;
  color: #0b5a2b;
  font-weight: 700;
}

.chip.taken.user {
  background: #dbeafe;
  color: #1e4b8a;
  font-weight: 700;
}

.chip.taken.mine {
  font-weight: 800;
}

.chip.taken.team.mine {
  background: #1f6b4a;
  color: #fff;
  box-shadow: inset 0 0 0 1px #0d3b28;
}

.chip.taken.user.mine {
  background: #1d4e89;
  color: #fff;
  box-shadow: inset 0 0 0 1px #102a4c;
}

.chip.free {
  background: var(--free-bg);
  color: var(--free);
  font-weight: 700;
}

.chip.free.team { box-shadow: inset 3px 0 0 #1f6b4a; }
.chip.free.user { box-shadow: inset 3px 0 0 #1d4e89; }

.chip.na { color: #c5bfb6; background: transparent; }

a.chip { text-decoration: none; }
a.chip.taken { text-decoration: underline dotted; text-underline-offset: 2px; }
a.chip.free:hover { filter: brightness(0.97); }
.chip.locked { cursor: default; }

.month-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.month-table th {
  text-align: center;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  padding: 0.45rem 0.15rem;
  background: #faf8f4;
}

.month-table th.is-weekend { color: #8a5a32; }

.month-table td {
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  vertical-align: top;
  padding: 0.35rem 0.28rem 0.5rem;
  background: #fff;
  overflow: hidden;
}

.month-table td:first-child { border-left: 0; }
.pc-day.weekend { background: #fcf8f2; }
.pc-day.out { background: #f4f1eb; }
.pc-day.is-today { background: #eef8f2; }

.pc-num {
  font-weight: 800;
  font-size: 0.92rem;
  line-height: 1.5rem;
  margin: 0 0 0.15rem 0.1rem;
}

.pc-day.is-today .pc-num {
  display: inline-flex;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.28rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
}

.pc-slot { margin-top: 0.28rem; }

.pc-time {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.pc-chips {
  display: grid;
  gap: 2px;
  margin-top: 1px;
}

.pc-plan .chip {
  display: block;
  min-height: 0;
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 0.78rem;
  line-height: 1.35;
  white-space: normal;
  overflow: visible;
}

.pc-plan .chip.na { display: none; }

.team-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
}

.team-badge.team { background: var(--taken-bg); color: var(--taken); }
.team-badge.user { background: #e8f1fb; color: #1d4e89; }
.team-badge.none { background: #f1efe9; color: #6b7280; }

.auth-wrap {
  max-width: 440px;
  margin: 2rem auto;
}

.auth-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.4rem 1.3rem 1.2rem;
  box-shadow: var(--shadow);
}

.team-note {
  background: #fff8ee;
  border: 1px solid #e7d3b0;
  border-left: 4px solid #8a5a32;
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  margin: 0 0 1rem;
  line-height: 1.45;
}

.team-note-ok {
  margin: 0.65rem 0 0;
  padding-top: 0.55rem;
  border-top: 1px solid #eadcc4;
  color: #3e4a42;
  font-size: 0.92rem;
}

.team-note strong { display: block; margin-bottom: 0.25rem; }
.team-note a { font-weight: 700; }

.password-suggest {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.55rem;
  margin-top: 0.5rem;
}

.password-suggest code {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: #f3f0ea;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
}

.user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.table-scroll {
  max-height: 460px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.missing { color: var(--free); font-weight: 700; }

.phone-plan .chip {
  white-space: normal;
  height: auto;
}

.hours-cell {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.45rem;
}

@media (min-width: 960px) {
  .phone-plan { display: none; }
  .pc-plan { display: block; }
}

@media (max-width: 959px) {
  .stack-wrap.table-responsive,
  .stack-wrap.card {
    background: transparent;
    border: 0;
    box-shadow: none;
    overflow: visible;
  }

  .table-scroll:has(.stack-table) {
    max-height: none;
    overflow: visible;
    border: 0;
    border-radius: 0;
  }

  .stack-table thead { display: none; }

  .stack-table,
  .stack-table tbody,
  .stack-table tr,
  .stack-table td {
    display: block;
    width: 100%;
  }

  .stack-table { background: transparent; }

  .stack-table tr {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    margin: 0 0 0.65rem;
    padding: 0.55rem 0.75rem 0.7rem;
    box-shadow: var(--shadow);
  }

  .stack-table td {
    border: 0;
    padding: 0.28rem 0;
    display: grid;
    grid-template-columns: 4.5rem minmax(0, 1fr);
    gap: 0.35rem;
    align-items: center;
    text-align: left !important;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .stack-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
  }

  .stack-table td.cell-title,
  .stack-table td.cell-actions {
    display: block;
  }

  .stack-table td.cell-title::before,
  .stack-table td.cell-actions::before { content: none; }

  .stack-table td.cell-title {
    font-weight: 800;
    font-size: 1.05rem;
    padding-bottom: 0.4rem;
    margin-bottom: 0.15rem;
    border-bottom: 1px solid var(--line);
  }

  .stack-table td.cell-actions { padding-top: 0.45rem; }

  .stack-table .user-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
  }

  .stack-table .user-actions .btn,
  .stack-table td.cell-actions > .btn {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .stack-table .chip {
    min-height: 36px;
    width: fit-content;
  }

  .hours-cell {
    display: grid;
    justify-items: stretch;
  }

  .hours-cell .btn {
    width: 100%;
    min-height: 44px;
  }

  .search-form,
  .import-form,
  .filter-form .card-body,
  .profile-head {
    flex-direction: column;
    align-items: stretch;
  }

  .search-form .btn,
  .import-form .btn,
  .filter-form .btn,
  .profile-head .btn,
  .profile-form .btn {
    width: 100%;
    min-height: 44px;
    white-space: normal;
  }

  .filter-form .card-body > div,
  .filter-form .form-control,
  .filter-form .form-select { width: 100%; }

  .card > .card-body:has(.stack-table) {
    padding-left: 0.55rem;
    padding-right: 0.55rem;
  }
}

@media (max-width: 720px) {
  .app-main { width: calc(100% - 1rem); padding-top: 0.75rem; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
  .team-line { grid-template-columns: 5.4rem 1fr; }
  .app-nav .nav-link { padding: 0.75rem 0.7rem; }
  h1 { font-size: 1.45rem; }
}

@media print {
  .app-nav, .ghost-bar, .no-print { display: none !important; }
  body { background: #fff; }
  .app-main { width: 100%; padding: 0; }
  .month-card { break-inside: avoid; box-shadow: none; }
  .phone-plan { display: none !important; }
  .pc-plan { display: block !important; }
}
