﻿:root {
  --bg-top: #f8f3e9;
  --bg-bottom: #e7f0ff;
  --surface: #ffffff;
  --surface-2: #f8fbff;
  --text: #10213a;
  --muted: #5d6f8a;
  --line: #d7e1ee;
  --primary: #0d5bd7;
  --primary-strong: #0a46a6;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --success: #067647;
  --success-bg: #ebfdf2;
  --shadow: 0 14px 34px rgba(17, 32, 53, 0.09);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  padding: 12px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(155deg, var(--bg-top), var(--bg-bottom));
}

.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  gap: 12px;
}

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

.panel-soft {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}

.heading-panel {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  margin: 0;
  color: #3a5d91;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2, h3, h4 { margin: 0; }

h1 { font-size: clamp(24px, 3vw, 34px); letter-spacing: -0.02em; }
h2 { font-size: clamp(22px, 2.5vw, 30px); letter-spacing: -0.02em; }
h3 { font-size: clamp(17px, 2vw, 21px); }

.subtitle {
  margin: 6px 0 0 0;
  color: var(--muted);
  font-size: 14px;
}

.heading-right { display: grid; gap: 8px; justify-items: end; }
.auth-row { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.auth-chip {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid #bfd3ef;
  background: #f5f9ff;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
}

.rev-badge {
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid #b9c7de;
  background: #edf4ff;
  color: #1a3b74;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.nav-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
  padding: 8px;
}

.nav-link {
  flex: 0 0 auto;
  text-decoration: none;
  color: #20426f;
  font-weight: 700;
  font-size: 13px;
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid #d7e3f4;
  background: #f8fbff;
  display: inline-flex;
  align-items: center;
}

.nav-link.active {
  background: #0d5bd7;
  color: #fff;
  border-color: #0d5bd7;
}

.notice {
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  font-weight: 600;
}
.notice.success { border-color: #9be0bc; background: var(--success-bg); color: var(--success); }
.notice.error { border-color: #ffc7c2; background: var(--danger-bg); color: var(--danger); }

.content-panel { display: grid; gap: 14px; }
.heading-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.week-heading-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
  flex: 1 1 auto;
  width: 100%;
}

.week-heading-inline h2 {
  line-height: 1.05;
  margin: 0;
}

.muted { color: var(--muted); }
.tiny { font-size: 12px; }

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

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

.stat-card strong { font-size: 20px; }

.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 1fr);
  gap: 12px;
}

.inline-form {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 10px;
}

.stack-form { display: grid; gap: 10px; }
.stack-form.two-up { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack-form .full { grid-column: 1 / -1; }

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

input, select { height: 42px; }
textarea { resize: vertical; min-height: 84px; }

.btn {
  border: 1px solid #0b4caf;
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  min-height: 40px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:hover { background: var(--primary-strong); }
.btn.secondary { border-color: var(--line); background: #fff; color: var(--text); }
.btn.danger { border-color: #b42318; background: #fff; color: #b42318; }

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: 0;
}

.check-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
}

.quick-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tip-list { margin: 0; padding-left: 18px; display: grid; gap: 8px; color: var(--muted); }

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

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

.table th {
  text-align: left;
  background: #f4f8ff;
  color: #2e4e7e;
  font-size: 13px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.table thead th {
  vertical-align: middle;
}

.table th,
.table td {
  border-bottom: 1px solid #e6edf7;
  padding: 10px;
  vertical-align: top;
}

.table td .btn { min-height: 32px; }
.table tr.summary-row td {
  background: #f0f6ff;
}

.table td.time-zero { background: #ffffff; }
.table td.time-under { background: #fff4d6; }
.table td.time-over { background: #e6f7ee; }
.table td.time-lvl-1 { background: #fbf6e6; }
.table td.time-lvl-2 { background: #f6eed0; }
.table td.time-lvl-3 { background: #e8f3de; }
.table td.time-lvl-4 { background: #d7ebca; }
.table td.time-lvl-5 { background: #bfe0ad; }

.stat-card.time-zero { background: #f8fbff; }
.stat-card.time-under { background: #fff4d6; }
.stat-card.time-over { background: #e6f7ee; }

.error {
  color: #b42318;
  background: #fff3f2;
  border: 1px solid #ffd5d1;
  padding: 10px;
  border-radius: 10px;
}

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

.week-toolbar {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.week-inline-nav {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  margin-top: 0;
  margin-left: 0;
  flex: 0 0 auto;
  position: relative;
}

.week-range-text {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
  line-height: 1;
}

.week-range-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 2px;
  cursor: pointer;
}

.week-shift-btn,
.week-calendar-btn {
  min-height: 30px;
  height: 30px;
  min-width: 30px;
  width: 30px;
  padding: 0;
}

.week-calendar-btn {
  margin-left: 2px;
  position: relative;
  overflow: hidden;
}

.week-picker-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0;
  margin: 0;
  border: 0;
  opacity: 0.01;
  pointer-events: auto;
  cursor: pointer;
  z-index: 2;
}

.week-picker-input::-webkit-calendar-picker-indicator {
  opacity: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.week-action-buttons {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.week-col-project,
.week-col-total,
.week-col-actions {
  font-size: 15px;
  vertical-align: middle;
}

.week-col-day {
  text-align: center !important;
  min-width: 64px;
  vertical-align: middle;
}

.week-col-day-name,
.week-col-day-date {
  display: inline;
  line-height: 1;
}

.week-col-day-name {
  font-size: 13px;
  font-weight: 700;
}

.week-col-day-date {
  font-size: 11px;
  color: #5a78a8;
  letter-spacing: 0.02em;
  text-transform: none;
  margin-left: 4px;
}

.week-col-total,
.week-col-actions {
  text-align: center !important;
}

.hidden { display: none; }

.inline-actions {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  min-height: 30px;
  height: 30px;
  min-width: 30px;
  padding: 0 8px;
}

.icon-btn svg {
  width: 14px;
  height: 14px;
  display: block;
}

@media (max-width: 900px) {
  body {
    padding: 10px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }

  .panel { padding: 12px; border-radius: 14px; }
  .heading-panel { flex-direction: column; }
  .heading-right { justify-items: start; }

  .split-grid { grid-template-columns: 1fr; }
  .inline-form { grid-template-columns: 1fr; }
  .stack-form.two-up { grid-template-columns: 1fr; }

  .table { min-width: 560px; }

  .nav-row {
    position: sticky;
    bottom: 8px;
    z-index: 40;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
  }

  .week-toolbar {
    width: 100%;
    justify-items: stretch;
  }

  .week-heading-inline {
    width: 100%;
    align-items: flex-start;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .week-inline-nav {
    margin-left: 0;
    flex-wrap: wrap;
  }

  .week-action-buttons {
    justify-content: stretch;
  }
}
