:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #eef4f7;
  --text: #18212f;
  --muted: #667085;
  --border: #d8e0e7;
  --primary: #1d63d8;
  --primary-dark: #164ca6;
  --accent: #0f766e;
  --danger: #b42318;
  --warning: #a16207;
  --shadow: 0 18px 45px rgba(24, 33, 47, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

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

button,
a.button {
  min-height: 42px;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.login-panel,
.workspace {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-panel {
  width: min(440px, 100%);
  margin: 12vh auto 0;
  padding: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand h1,
.brand p {
  margin: 0;
}

.brand h1 {
  font-size: 1.45rem;
}

.brand p {
  color: var(--muted);
  font-size: 0.95rem;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: var(--radius);
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
}

.compact-brand .brand-mark {
  width: 38px;
  height: 38px;
  flex-basis: 38px;
}

.compact-brand h1 {
  font-size: 1.15rem;
}

.form-grid,
.inline-form,
.entry-form,
.admin-form,
.stats-form,
.toolbar {
  display: grid;
  gap: 14px;
}

.form-grid {
  margin-top: 28px;
}

.compact {
  grid-template-columns: 1fr;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
  padding: 9px 11px;
  outline: none;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 99, 216, 0.14);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 9px 14px;
  color: var(--text);
  background: #ffffff;
  cursor: pointer;
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
}

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

.button.primary:hover {
  background: var(--primary-dark);
}

.button.secondary {
  background: #e9f3f2;
  border-color: #b9dcda;
  color: #0f5f58;
}

.button.ghost {
  background: transparent;
  border-color: var(--border);
}

.button.danger {
  background: #fff1f0;
  border-color: #f2b8b5;
  color: var(--danger);
}

.message {
  min-height: 24px;
  color: var(--danger);
  font-weight: 700;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

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

.tab-button {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--muted);
  padding: 7px 12px;
  cursor: pointer;
  font-weight: 700;
}

.tab-button.active {
  background: var(--text);
  border-color: var(--text);
  color: #ffffff;
}

.workspace {
  padding: 20px;
}

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

.section-heading h2,
.section-heading p {
  margin: 0;
}

.section-heading h2 {
  font-size: 1.35rem;
}

.section-heading p {
  color: var(--muted);
}

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

.inline-form,
.toolbar {
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: end;
  margin-bottom: 16px;
  padding: 14px;
  background: var(--surface-soft);
  border-radius: var(--radius);
}

.toolbar {
  grid-template-columns: minmax(0, 1fr) auto auto auto auto;
}

.timesheet-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--muted);
  font-weight: 700;
}

.timesheet-info strong {
  color: var(--text);
}

.entry-form {
  grid-template-columns: 150px minmax(180px, 1fr) 120px 120px 110px minmax(180px, 1.2fr) auto;
  align-items: end;
  margin: 18px 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.empty-state {
  padding: 34px 18px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  background: #ffffff;
}

.table-panel {
  margin-top: 16px;
}

.table-summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
  color: var(--muted);
}

.table-summary strong {
  color: var(--text);
  font-size: 1.05rem;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
}

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

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

th {
  background: #f0f5f8;
  color: #344054;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

tbody tr:last-child td {
  border-bottom: 0;
}

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

.small-button {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
  padding: 5px 9px;
  cursor: pointer;
  font-weight: 700;
}

.small-button.danger {
  color: var(--danger);
  border-color: #f2b8b5;
  background: #fff7f7;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.82rem;
}

.status.active,
.status.open,
.status.employee {
  background: #e9f3f2;
  color: var(--accent);
}

.status.inactive,
.status.closed {
  background: #f2f4f7;
  color: #475467;
}

.status.admin {
  background: #fff7e6;
  color: var(--warning);
}

.admin-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.admin-form,
.stats-form {
  grid-template-columns: repeat(4, minmax(150px, 1fr)) auto;
  align-items: end;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.admin-form .wide {
  grid-column: span 2;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  color: var(--text);
}

.check-label input {
  width: auto;
  min-height: auto;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%) translateY(20px);
  max-width: min(520px, calc(100% - 24px));
  padding: 12px 16px;
  background: var(--text);
  color: #ffffff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  font-weight: 700;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

[hidden] {
  display: none !important;
}

@media (max-width: 960px) {
  .entry-form,
  .admin-form,
  .stats-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .note-field,
  .admin-form .wide {
    grid-column: 1 / -1;
  }

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

@media (max-width: 720px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding: 10px 0 22px;
  }

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

  .login-panel {
    margin-top: 8vh;
  }

  .topbar,
  .section-heading {
    display: grid;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions > * {
    flex: 1 1 auto;
  }

  .inline-form,
  .toolbar,
  .entry-form,
  .admin-form,
  .stats-form {
    grid-template-columns: 1fr;
  }

  .table-scroll {
    border: 0;
    overflow: visible;
    background: transparent;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  tr {
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #ffffff;
    overflow: hidden;
  }

  td {
    display: grid;
    grid-template-columns: minmax(98px, 34%) minmax(0, 1fr);
    gap: 10px;
    border-bottom: 1px solid var(--border);
    word-break: break-word;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 700;
  }

  td:last-child {
    border-bottom: 0;
  }

  .row-actions {
    justify-content: flex-start;
  }
}
