:root {
  --bg: #f4f7fb;
  --bg-2: #edf3fa;
  --panel: #ffffff;
  --line: #dbe5ef;
  --line-strong: #c9d7e5;
  --text: #12212f;
  --muted: #5d6f80;
  --primary: #0a84ff;
  --primary-2: #0a84ff;
  --warning: #d98018;
  --danger: #c44545;
  --success: #1f8f5b;
  --shadow: 0 8px 22px rgba(15, 30, 45, 0.08);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  color: var(--text);
  font-family:
    "SF Pro Text",
    "SF Pro Display",
    -apple-system,
    "BlinkMacSystemFont",
    "Segoe UI",
    "Helvetica Neue",
    Arial,
    sans-serif;
  background:
    radial-gradient(circle at 10% 4%, #ffffff 0%, transparent 28%),
    linear-gradient(165deg, var(--bg) 0%, var(--bg-2) 100%);
}

.app-shell {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  min-height: 100vh;
}

.side-nav {
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  border-right: 1px solid var(--line);
  background: #f7fbff;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 750;
  letter-spacing: 0.2px;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.93rem;
}

.view-nav {
  margin-top: 18px;
  display: grid;
  gap: 8px;
}

.settings-nav {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.settings-btn {
  width: 100%;
}

.nav-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 11px;
  padding: 10px 12px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  text-align: left;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition:
    transform 120ms ease,
    background 120ms ease,
    color 120ms ease,
    border-color 120ms ease;
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  flex: 0 0 18px;
}

.nav-icon svg {
  width: 100%;
  height: 100%;
}

.nav-label {
  line-height: 1.1;
}

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

.nav-btn:hover {
  transform: translateY(-1px);
  background: #f4f8fc;
}

.main-content {
  padding: 16px 16px 30px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
  padding: 10px 2px 12px;
  border-bottom: 1px solid var(--line);
}

.topbar h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 740;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.status {
  margin: 0;
  color: var(--primary);
  font-weight: 650;
  font-size: 0.88rem;
  text-align: right;
  max-width: 420px;
}

.status.error {
  color: var(--danger);
}

.view {
  display: none;
  animation: enter 200ms ease;
}

.view.active {
  display: grid;
  gap: 12px;
}

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

.card h3 {
  margin: 2px 0 10px;
  font-size: 1.03rem;
  font-weight: 730;
}

.card h4 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.96rem;
}

.hidden {
  display: none !important;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fbff;
  padding: 12px;
}

.stat-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.42rem;
  font-weight: 760;
}

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

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

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 0.91rem;
}

.switch-field {
  flex-direction: row !important;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
}

.switch-field input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--primary);
}

.switch-field span {
  font-size: 0.92rem;
  color: var(--text);
  font-weight: 600;
}

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

.actions-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: flex-end;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 11px;
  padding: 9px 10px;
  transition:
    border-color 120ms ease,
    box-shadow 120ms ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #5aa9ff;
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.18);
}

select[multiple] {
  min-height: 140px;
}

button {
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 12px;
  color: #fff;
  background: var(--primary);
  font-weight: 680;
  cursor: pointer;
  align-self: end;
  min-height: 42px;
  transition:
    transform 120ms ease,
    background-color 120ms ease,
    box-shadow 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  background: #0874e0;
}

button.danger {
  background: var(--danger);
}

button.ghost {
  background: #f4f8fd;
  color: #265b84;
  border: 1px solid #c8d7e6;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.file-label {
  display: block;
  border: 1px dashed #9ec2cf;
  border-radius: 10px;
  padding: 10px;
  background: rgba(240, 250, 255, 0.75);
}

.file-label input {
  margin-top: 6px;
  width: 100%;
}

.inline-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 10px;
  background: #f8fbff;
}

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.hint.compact {
  margin: 0 0 6px;
}

.sw-note {
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fbff;
  color: var(--muted);
  font-size: 0.84rem;
}

.sw-note.tone-ok {
  color: #1d7047;
  border-color: #c5e2d0;
  background: #eefaf3;
}

.sw-note.tone-warning {
  color: #7a521b;
  border-color: #eed8b5;
  background: #fff7ea;
}

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

.morning-filters {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.morning-filters button {
  width: 100%;
}

.toggle-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toggle-pill {
  border: 1px solid #bbcfdf;
  border-radius: 999px;
  padding: 6px 10px;
  background: #f2f7fc;
  color: #2f5f82;
  font-weight: 600;
  align-self: auto;
}

.toggle-pill.selected {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
}

.status-inline {
  margin: 8px 0 0;
  color: #0c6173;
  font-weight: 600;
}

.calendar-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.calendar-toolbar input[type="month"] {
  max-width: 180px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
  min-width: 760px;
}

.calendar-head {
  text-align: center;
  font-weight: 700;
  color: #0d5468;
  font-size: 0.88rem;
}

.calendar-cell {
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.calendar-cell.empty {
  background: rgba(255, 255, 255, 0.45);
  border-style: dashed;
}

.calendar-cell.has-events {
  background: #f5fbff;
}

.calendar-cell.selected {
  border-color: #0f8194;
  box-shadow: inset 0 0 0 1px #0f8194;
}

.calendar-day {
  font-weight: 700;
}

.calendar-badges {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.event-badge {
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.74rem;
  font-weight: 700;
  color: #fff;
  display: inline-flex;
  width: fit-content;
}

.event-badge.meeting {
  background: #0f7f95;
}

.event-badge.travel {
  background: #f08b45;
}

.event-badge.stay {
  background: #1d8e52;
}

.day-events {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.search-results {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.search-results a {
  text-decoration: none;
  color: #1f5f8f;
  border: 1px solid #c2d6e7;
  border-radius: 999px;
  padding: 8px 12px;
  background: #f3f8fd;
}

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

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

th,
td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
  vertical-align: top;
}

th {
  color: #2d4d67;
  background: #f5f9fd;
  border-top: 1px solid var(--line);
}

tbody tr:hover {
  background: #f9fcff;
}

td button {
  padding: 6px 8px;
  font-size: 0.84rem;
  min-height: 34px;
}

.actions-inline {
  display: flex;
  gap: 6px;
}

.actions-inline button {
  align-self: auto;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.76rem;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}

.status-badge.tone-critical {
  color: #8d2d2d;
  background: #ffefef;
  border-color: #f0c0c0;
}

.status-badge.tone-warning {
  color: #7a521b;
  background: #fff3e3;
  border-color: #edd4ac;
}

.status-badge.tone-ok {
  color: #155f93;
  background: #ebf5ff;
  border-color: #bdd9f4;
}

.status-badge.tone-done {
  color: #1d7047;
  background: #e9f8f0;
  border-color: #bbe2ca;
}

.status-badge.tone-neutral {
  color: #51656d;
  background: #eef4f7;
  border-color: #ccdbe1;
}

.agenda-type {
  display: inline-flex;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 700;
}

.agenda-type.meeting {
  color: #155f93;
  background: #ebf5ff;
}

.agenda-type.travel {
  color: #7a521b;
  background: #fff3e3;
}

.agenda-type.stay {
  color: #1d7047;
  background: #e9f8f0;
}

.priority-badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.76rem;
  font-weight: 700;
}

.priority-badge.high {
  color: #fff;
  background: #be3a3a;
}

.priority-badge.medium {
  color: #684005;
  background: #ffdca8;
}

.mobile-nav {
  display: none;
}

body.hide-nav-icons .nav-icon {
  display: none;
}

body.hide-nav-labels .nav-label {
  display: none;
}

body.hide-nav-labels .side-nav .nav-btn,
body.hide-nav-labels .mobile-nav .nav-btn {
  justify-content: center;
}

body.hide-nav-labels .mobile-nav .nav-btn {
  flex-basis: 56px;
  min-height: 52px;
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1180px) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .morning-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-nav {
    display: none;
  }

  .main-content {
    padding: 12px 12px calc(98px + env(safe-area-inset-bottom, 0px));
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    margin: -12px -12px 10px;
    padding: 10px 12px;
    background: #f3fbff;
    border-bottom: 1px solid #d5e6ee;
  }

  .topbar h2 {
    font-size: 1.08rem;
  }

  .subtitle {
    font-size: 0.82rem;
  }

  .status {
    text-align: left;
    max-width: none;
    font-size: 0.82rem;
  }

  .grid-two,
  .form-grid,
  .morning-filters,
  .filter-grid {
    grid-template-columns: 1fr;
  }

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

  .stat-card strong {
    font-size: 1.2rem;
  }

  .card {
    padding: 12px;
    backdrop-filter: none;
    background: #fff;
    box-shadow: 0 8px 20px rgba(13, 44, 56, 0.08);
  }

  input,
  select,
  textarea {
    min-height: 44px;
    border-radius: 12px;
  }

  .mobile-nav {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    display: flex;
    align-items: stretch;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid #cddde4;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 10px 22px rgba(13, 44, 56, 0.16);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-nav::-webkit-scrollbar {
    display: none;
  }

  .mobile-nav .nav-btn {
    flex: 0 0 74px;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 4px;
    text-align: center;
    padding: 7px 4px;
    font-size: 0.68rem;
    font-weight: 700;
    min-height: 58px;
    border-radius: 12px;
  }

  .mobile-nav .nav-btn.active {
    box-shadow: 0 4px 12px rgba(12, 91, 115, 0.24);
  }

  .mobile-nav .nav-icon {
    width: 16px;
    height: 16px;
    flex-basis: 16px;
  }

  table {
    min-width: 680px;
  }

  th,
  td {
    font-size: 0.86rem;
    padding: 7px;
  }
}

@media (max-width: 520px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .mobile-nav .nav-btn {
    flex-basis: 68px;
    min-height: 56px;
    font-size: 0.64rem;
  }

  .mobile-nav .nav-icon {
    width: 15px;
    height: 15px;
    flex-basis: 15px;
  }

  .mobile-nav .nav-label {
    letter-spacing: 0.1px;
  }
}
