:root {
  --ink: #19242f;
  --muted: #62717f;
  --line: #d8e0e6;
  --wash: #f4f7f8;
  --paper: #ffffff;
  --brand: #145c64;
  --brand-2: #9f6a39;
  --brand-3: #2f7b88;
  --danger: #a94343;
  --shadow: 0 16px 40px rgba(25, 36, 47, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(20, 92, 100, 0.11), transparent 32%),
    linear-gradient(315deg, rgba(159, 106, 57, 0.13), transparent 30%),
    var(--wash);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

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

button {
  cursor: pointer;
}

code {
  border-radius: 5px;
  background: #edf2f4;
  padding: 2px 5px;
}

.login-screen {
  display: grid;
  grid-template-columns: minmax(300px, 0.85fr) minmax(360px, 1.15fr);
  min-height: 100vh;
}

.brand-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px;
  color: white;
  background:
    linear-gradient(rgba(16, 58, 64, 0.74), rgba(16, 58, 64, 0.84)),
    url("https://images.unsplash.com/photo-1557804506-669a67965ba0?auto=format&fit=crop&w=1600&q=80") center/cover;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-symbol {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--brand);
  background: white;
  border-radius: 8px;
  font-weight: 800;
}

.brand-logo {
  display: block;
  width: 122px;
  height: auto;
  flex: 0 0 auto;
}

.login-screen .brand-logo {
  width: 112px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  padding: 7px 8px;
}

.brand-panel h1 {
  max-width: 660px;
  margin: 0;
  font-size: clamp(2.4rem, 5vw, 5.8rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.brand-panel p {
  max-width: 570px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 1.05rem;
  line-height: 1.65;
}

.login-panel {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px;
}

.login-panel.single {
  min-height: 100vh;
}

.login-card {
  width: min(100%, 480px);
  padding: 32px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand-2);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

.subtle {
  color: var(--muted);
  line-height: 1.55;
}

.form-stack {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

label {
  display: grid;
  gap: 7px;
  color: #324352;
  font-size: 0.86rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand-3);
  box-shadow: 0 0 0 3px rgba(47, 123, 136, 0.14);
}

textarea {
  min-height: 86px;
  resize: vertical;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  font-weight: 800;
}

.primary-btn {
  padding: 12px 16px;
  color: white;
  background: var(--brand);
}

.secondary-btn {
  padding: 10px 14px;
  color: var(--brand);
  background: #e7f1f2;
}

.ghost-btn {
  padding: 10px 12px;
  color: var(--ink);
  background: transparent;
}

.icon-btn {
  width: 38px;
  height: 38px;
  color: var(--ink);
  background: #edf2f4;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  padding: 14px 24px;
  backdrop-filter: blur(14px);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  text-transform: capitalize;
}

.avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: white;
  font-weight: 800;
}

.workspace {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 24px;
  padding: 24px;
}

.sidebar {
  align-self: start;
  position: sticky;
  top: 88px;
  display: grid;
  gap: 18px;
}

.nav-panel,
.content-panel,
.summary-card,
.day-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
}

.nav-panel {
  padding: 12px;
}

.nav-btn {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 12px;
  color: #31424f;
  font-weight: 800;
  text-align: left;
}

.nav-btn.active {
  color: white;
  background: var(--brand);
}

.content {
  display: grid;
  gap: 18px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.page-title {
  display: grid;
  gap: 6px;
}

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

.content-panel {
  padding: 18px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.weekday {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.day-cell {
  min-height: 110px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  padding: 9px;
  text-align: left;
}

.day-cell.outside {
  opacity: 0.42;
}

.day-number {
  display: flex;
  justify-content: space-between;
  font-weight: 800;
}

.entry-count {
  color: var(--brand);
  font-size: 0.78rem;
}

.day-snippet {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.split-view {
  display: grid;
  grid-template-columns: minmax(360px, 1.05fr) minmax(320px, 0.95fr);
  gap: 18px;
}

.day-panel {
  overflow: hidden;
}

.day-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 16px;
}

.hour-list {
  display: grid;
  max-height: 650px;
  overflow: auto;
}

.hour-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
}

.hour-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  padding-top: 12px;
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(0, 1fr);
  gap: 8px;
}

.panel-actions {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  padding: 14px 16px;
}

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

.admin-grid {
  grid-template-columns: minmax(320px, 0.8fr) minmax(320px, 1.2fr);
}

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

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

.table-wrap {
  overflow: auto;
}

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

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

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

.tag {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 9px;
  color: var(--brand);
  background: #e6f1f2;
  font-size: 0.78rem;
  font-weight: 800;
}

.notice {
  border-left: 4px solid var(--brand-2);
  background: #fff8ef;
  padding: 12px 14px;
  color: #5c4733;
  line-height: 1.5;
}

.alert {
  border-radius: 6px;
  padding: 12px 14px;
  background: #e8f5ee;
  color: #205c42;
}

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

.inline-form {
  display: flex;
  gap: 8px;
  margin: 14px 0;
}

@media (max-width: 980px) {
  .login-screen,
  .workspace,
  .split-view,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .brand-panel {
    min-height: 48vh;
  }

  .sidebar {
    position: static;
  }
}

@media (max-width: 680px) {
  body {
    background: var(--wash);
    padding-bottom: 76px;
  }

  .app-topbar,
  .page-header {
    align-items: stretch;
    flex-direction: column;
  }

  .app-topbar {
    gap: 12px;
    padding: 12px 14px;
  }

  .app-topbar .brand-mark span:last-child {
    font-size: 0.98rem;
  }

  .app-topbar .toolbar {
    justify-content: space-between;
  }

  .user-pill {
    min-width: 0;
    font-size: 0.84rem;
  }

  .avatar {
    width: 34px;
    height: 34px;
  }

  .workspace,
  .login-panel,
  .brand-panel {
    padding: 14px;
  }

  .workspace {
    display: block;
  }

  .sidebar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 10;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    backdrop-filter: blur(14px);
  }

  .nav-panel {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    border: 0;
    background: transparent;
    padding: 0;
  }

  .nav-btn {
    justify-content: center;
    min-height: 44px;
    padding: 8px 6px;
    font-size: 0.76rem;
    text-align: center;
  }

  .nav-btn[href="notes.php"] {
    display: none;
  }

  .content {
    gap: 14px;
  }

  .page-header {
    gap: 12px;
  }

  .page-title h2 {
    font-size: 1.45rem;
    line-height: 1.15;
  }

  .page-title .subtle {
    margin: 0;
    font-size: 0.92rem;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .toolbar .icon-btn,
  .toolbar .secondary-btn,
  .toolbar .primary-btn,
  .toolbar select,
  .toolbar input {
    width: 100%;
    min-height: 46px;
  }

  .toolbar .icon-btn {
    width: 100%;
  }

  .content-panel {
    padding: 12px;
  }

  .calendar-grid {
    display: block;
  }

  .weekday {
    display: none;
  }

  .day-cell {
    display: block;
    min-height: auto;
    margin-bottom: 8px;
    padding: 12px;
  }

  .day-cell.outside {
    display: none;
  }

  .day-number {
    align-items: center;
    font-size: 1rem;
  }

  .entry-count {
    display: inline-flex;
    border-radius: 999px;
    background: #e6f1f2;
    padding: 3px 8px;
  }

  .day-snippet {
    display: block;
    margin-top: 6px;
    font-size: 0.84rem;
  }

  .hour-row,
  .field-grid,
  .insights-grid {
    grid-template-columns: 1fr;
  }

  .split-view {
    display: block;
  }

  .day-panel {
    border-radius: 8px;
  }

  .day-panel-header {
    align-items: flex-start;
    padding: 14px;
  }

  .day-panel-header h3 {
    font-size: 1rem;
  }

  .day-panel-header .subtle {
    margin: 5px 0 0;
    font-size: 0.84rem;
  }

  .hour-list {
    max-height: none;
    overflow: visible;
  }

  .hour-row {
    gap: 8px;
    padding: 14px;
  }

  .hour-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 0;
    color: var(--ink);
    font-size: 0.95rem;
  }

  .field-grid {
    gap: 10px;
  }

  input,
  select,
  textarea {
    min-height: 46px;
    padding: 12px;
    font-size: 16px;
  }

  textarea {
    min-height: 58px;
  }

  .hour-row:focus-within textarea {
    min-height: 116px;
  }

  .panel-actions {
    position: sticky;
    bottom: 68px;
    z-index: 8;
    background: rgba(255, 255, 255, 0.96);
    padding: 10px;
    backdrop-filter: blur(14px);
  }

  .panel-actions .primary-btn {
    width: 100%;
    min-height: 48px;
  }

  .split-view > .content-panel {
    margin-top: 14px;
  }

  .admin-grid,
  .inline-form {
    display: grid;
    grid-template-columns: 1fr;
  }

  .metric {
    padding: 12px;
  }

  .metric strong {
    font-size: 1.35rem;
  }

  .table-wrap {
    margin-right: -12px;
    margin-left: -12px;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  table {
    min-width: 700px;
  }

  .login-screen {
    display: block;
    min-height: 100svh;
  }

  .brand-panel {
    min-height: auto;
    gap: 18px;
    justify-content: flex-start;
    padding: 28px 18px 22px;
    background-position: center top;
  }

  .brand-panel .brand-mark {
    align-items: center;
    gap: 10px;
  }

  .brand-panel .brand-mark span:last-child {
    font-size: 1.15rem;
    line-height: 1.15;
  }

  .brand-panel .brand-symbol {
    width: 52px;
    height: 52px;
  }

  .brand-panel .eyebrow {
    margin-bottom: 7px;
    font-size: 0.68rem;
  }

  .brand-panel h1 {
    max-width: 340px;
    font-size: 2rem;
    line-height: 1.05;
  }

  .brand-panel > div p:not(.eyebrow),
  .brand-panel > p {
    display: none;
  }

  .login-panel {
    min-height: auto;
    place-items: start center;
    padding: 16px 14px 28px;
  }

  .login-card {
    padding: 20px;
    box-shadow: 0 10px 28px rgba(25, 36, 47, 0.1);
  }

  .login-card .subtle {
    margin: 8px 0 0;
    font-size: 0.9rem;
  }

  .login-card .form-stack {
    gap: 14px;
    margin-top: 18px;
  }
}

@media (max-width: 980px) {
  .login-screen {
    display: block;
    min-height: 100svh;
  }

  .login-screen .brand-panel {
    min-height: auto;
    gap: 18px;
    justify-content: flex-start;
    padding: 28px 18px 22px;
    background-position: center top;
  }

  .login-screen .brand-panel .brand-mark {
    align-items: center;
    gap: 10px;
  }

  .login-screen .brand-panel .brand-mark span:last-child {
    font-size: 1.15rem;
    line-height: 1.15;
  }

  .login-screen .brand-panel .brand-symbol {
    width: 52px;
    height: 52px;
  }

  .login-screen .brand-panel .eyebrow {
    margin-bottom: 7px;
    font-size: 0.68rem;
  }

  .login-screen .brand-panel h1 {
    max-width: 340px;
    font-size: 2rem;
    line-height: 1.05;
  }

  .login-screen .brand-panel > div p:not(.eyebrow),
  .login-screen .brand-panel > p {
    display: none;
  }

  .login-screen .login-panel {
    min-height: auto;
    place-items: start center;
    padding: 16px 14px 28px;
  }

  .login-screen .login-card {
    padding: 20px;
    box-shadow: 0 10px 28px rgba(25, 36, 47, 0.1);
  }

  .login-screen .login-card .subtle {
    margin: 8px 0 0;
    font-size: 0.9rem;
  }

  .login-screen .login-card .form-stack {
    gap: 14px;
    margin-top: 18px;
  }
}

@media (max-width: 680px) {
  body:has(.app-topbar) {
    padding-bottom: 0;
  }

  .app-topbar {
    position: static;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
  }

  .app-topbar .brand-mark {
    min-width: 0;
    gap: 9px;
  }

  .app-topbar .brand-logo {
    width: 72px;
  }

  .app-topbar .brand-mark span:last-child {
    font-size: 0.92rem;
    line-height: 1.08;
  }

  .app-topbar .toolbar {
    display: flex;
    width: auto;
    flex: 0 0 auto;
    justify-content: flex-end;
    gap: 6px;
  }

  .app-topbar .user-pill span:last-child,
  .app-topbar .ghost-btn {
    display: none;
  }

  .app-topbar .avatar {
    width: 34px;
    height: 34px;
  }

  .workspace {
    display: grid;
    gap: 12px;
    padding: 12px;
  }

  .sidebar {
    position: static;
    border-top: 0;
    background: transparent;
    padding: 0;
    backdrop-filter: none;
  }

  .nav-panel {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.94);
    padding: 8px;
    scrollbar-width: none;
  }

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

  .nav-btn {
    width: auto;
    flex: 0 0 auto;
    min-height: 36px;
    padding: 8px 10px;
    white-space: nowrap;
    font-size: 0.82rem;
  }

  .nav-btn[href="notes.php"] {
    display: none;
  }

  .page-header {
    display: grid;
    gap: 12px;
  }

  .page-title h2 {
    font-size: 1.75rem;
  }

  .content > .page-header > .toolbar {
    display: flex;
    width: 100%;
    flex-wrap: nowrap;
    gap: 7px;
    align-items: center;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .content > .page-header > .toolbar::-webkit-scrollbar {
    display: none;
  }

  .content > .page-header > .toolbar select {
    min-width: 132px;
    width: auto;
  }

  .content > .page-header > .toolbar .secondary-btn,
  .content > .page-header > .toolbar .primary-btn {
    width: auto;
    min-width: 0;
    min-height: 38px;
    padding: 8px 12px;
    white-space: nowrap;
  }

  .content > .page-header > .toolbar .icon-btn {
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
    font-size: 1rem;
  }

  .calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 5px;
  }

  .weekday {
    display: block;
    font-size: 0.62rem;
  }

  .day-cell,
  .day-cell.outside {
    display: block;
  }

  .day-cell {
    min-height: 62px;
    margin-bottom: 0;
    padding: 7px;
  }

  .day-number {
    display: block;
    font-size: 0.84rem;
  }

  .entry-count {
    display: block;
    margin-top: 2px;
    padding: 0;
    background: transparent;
    font-size: 0.58rem;
  }

  .day-snippet {
    margin-top: 5px;
    font-size: 0.62rem;
    line-height: 1.25;
  }
}
