:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --ink: #172033;
  --muted: #637085;
  --line: #d9e0ea;
  --accent: #2563eb;
  --green: #0f766e;
  --amber: #b45309;
  --red: #be123c;
  --shadow: 0 14px 38px rgba(23, 32, 51, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

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

button,
.pill-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

button.danger {
  border-color: rgba(190, 18, 60, 0.35);
  background: rgba(190, 18, 60, 0.08);
  color: var(--red);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

input,
select,
textarea {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

textarea {
  min-height: 72px;
  padding: 10px;
  resize: vertical;
}

.app-shell {
  min-height: 100vh;
}

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

.login-box {
  display: grid;
  width: min(100%, 360px);
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 22px;
  box-shadow: var(--shadow);
}

.login-error {
  margin: 0;
  color: var(--red);
  font-size: 13px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 12px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 247, 244, 0.92);
  backdrop-filter: blur(12px);
}

.brand {
  display: grid;
  gap: 2px;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.brand span {
  color: var(--muted);
  font-size: 13px;
}

.user-switch {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.user-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}

.user-button.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.dot {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 999px;
  background: var(--accent);
}

.layout {
  display: grid;
  grid-template-columns: minmax(250px, 300px) minmax(0, 1fr);
  min-height: calc(100vh - 72px);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #fbfcfb;
  padding: 22px;
}

.main {
  padding: 24px 28px 40px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-title h2,
.section-title h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.company-form {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
}

.company-form button {
  width: 100%;
}

.company-list {
  display: grid;
  gap: 8px;
}

.company-button {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
  text-align: left;
}

.company-button.active {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
}

.company-button strong {
  font-size: 14px;
}

.company-button span {
  color: var(--muted);
  font-size: 12px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.summary-item {
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  box-shadow: var(--shadow);
}

.summary-item span {
  color: var(--muted);
  font-size: 12px;
}

.summary-item strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.period-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.period-control label {
  color: var(--muted);
  font-size: 12px;
}

.period-control input {
  min-width: 156px;
}

.period-chips {
  margin: -6px 0 16px;
}

.company-notes {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  box-shadow: var(--shadow);
}

.company-note-list {
  display: grid;
  gap: 8px;
  max-height: 168px;
  overflow: auto;
}

.company-note {
  display: grid;
  gap: 4px;
  border-left: 3px solid var(--accent);
  padding-left: 10px;
}

.company-note div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.company-note p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.company-note-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
}

.sync-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.sync-state::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--green);
}

.task-dashboard {
  display: grid;
  gap: 22px;
}

.task-section {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.task-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.task-section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.task-section-head h3 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0;
}

.task-section-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.task-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 14px;
}

.task-card {
  display: grid;
  gap: 12px;
  min-height: 234px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  box-shadow: var(--shadow);
}

.task-card[data-status="done"] {
  border-color: rgba(15, 118, 110, 0.35);
}

.task-card[data-status="doing"] {
  border-color: rgba(180, 83, 9, 0.35);
}

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

.task-name {
  margin: 0 0 8px;
  font-weight: 750;
}

.task-meta,
.assignees,
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  padding: 0 8px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.chip.done {
  border-color: rgba(15, 118, 110, 0.28);
  background: rgba(15, 118, 110, 0.08);
  color: var(--green);
}

.chip.doing {
  border-color: rgba(180, 83, 9, 0.28);
  background: rgba(180, 83, 9, 0.08);
  color: var(--amber);
}

.task-controls {
  display: grid;
  gap: 10px;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.control-row label {
  color: var(--muted);
  font-size: 12px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  min-width: 196px;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.segmented button {
  border: 0;
  border-radius: 0;
  background: #fff;
}

.segmented button.active {
  background: var(--ink);
  color: #fff;
}

.employee-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
}

.employee-toggle input {
  width: 14px;
  min-height: 14px;
  accent-color: var(--accent);
}

.note-list {
  display: grid;
  gap: 6px;
  max-height: 96px;
  overflow: auto;
}

.note {
  border-left: 3px solid var(--line);
  padding-left: 8px;
  color: var(--muted);
  font-size: 13px;
}

.note div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.note p {
  margin: 4px 0 0;
}

.note strong {
  color: var(--ink);
}

.note-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
}

.time-panel {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 16px;
  margin-top: 22px;
}

.time-form,
.time-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  box-shadow: var(--shadow);
}

.time-form {
  display: grid;
  gap: 10px;
  align-content: start;
}

.time-list {
  max-height: 420px;
  overflow: auto;
}

.time-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.time-row:first-child {
  padding-top: 0;
}

.time-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.time-row strong {
  color: var(--accent);
}

.time-row p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 980px) {
  .layout,
  .time-panel {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

@media (max-width: 680px) {
  .topbar {
    align-items: start;
    flex-direction: column;
    padding: 14px;
  }

  .user-switch {
    justify-content: start;
  }

  .sidebar,
  .main {
    padding: 16px;
  }

  .summary-grid,
  .task-grid {
    grid-template-columns: 1fr;
  }

  .task-head,
  .section-title,
  .section-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .note-form {
    grid-template-columns: 1fr;
  }

  .company-note-form {
    grid-template-columns: 1fr;
  }
}
