:root {
  --bg: #e8edf6;
  --card: #ffffff;
  --card-border: #d9e1ef;
  --text: #18202d;
  --muted: #687387;
  --primary: #1b5cff;
  --primary-dark: #1548c9;
  --ok-bg: #edf8ef;
  --ok-border: #c6e6cb;
  --ok-text: #22623b;
  --err-bg: #fff1f1;
  --err-border: #f0c8c8;
  --err-text: #9b2d2d;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: linear-gradient(180deg, #edf2f8 0%, #dfe7f3 100%);
  color: var(--text);
  overflow-x: hidden;
  width: 100%;
  max-width: 100%;
}

.shell {
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  padding: 18px 12px;
  display: flex;
  justify-content: center;
}

.card {
  width: min(100%, 460px);
  max-width: 460px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  box-shadow: 0 12px 32px rgba(24, 32, 45, 0.08);
  padding: 20px 16px 18px;
  overflow: hidden;
}

.hero {
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
}

h1 {
  margin: 0 0 6px;
  font-size: 26px;
  line-height: 1.1;
}

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

.panel {
  margin-top: 14px;
  min-width: 0;
}

.hidden {
  display: none;
}

label {
  display: block;
  margin: 14px 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: #3b4554;
}

input,
button {
  font: inherit;
}

input {
  width: 100%;
  inline-size: 100%;
  max-inline-size: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid #cfd8e6;
  background: #f8fafd;
  color: var(--text);
  max-width: 100%;
  min-width: 0;
}

input:focus {
  outline: none;
  border-color: var(--primary);
  background: #ffffff;
}

.native-field {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.native-display {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid #cfd8e6;
  background: #f8fafd;
  color: var(--text);
  display: flex;
  align-items: center;
}

.native-display.is-placeholder {
  color: var(--muted);
}

.native-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0.01;
  cursor: pointer;
}

.time-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: end;
  width: 100%;
  min-width: 0;
}

.field {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

form {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.primary-btn,
.icon-btn,
.tab-btn {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.primary-btn {
  width: 100%;
  min-height: 50px;
  margin-top: 20px;
  background: linear-gradient(135deg, var(--primary) 0%, #6a3de8 100%);
  color: #ffffff;
  font-weight: 700;
  border-radius: 14px;
}

.primary-btn:hover {
  background: linear-gradient(135deg, var(--primary-dark) 0%, #5630c2 100%);
}

.primary-btn:disabled,
.icon-btn:disabled,
.tab-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  color: #7a8597;
  font-size: 28px;
  line-height: 1;
}

.icon-btn:hover {
  background: #eef3fb;
  color: #274160;
}

.user-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.user-value {
  margin: 0;
  font-weight: 700;
  font-size: 19px;
}

.user-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.tab-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
  padding: 4px;
  border-radius: 14px;
  background: #eef3fb;
}

.tab-btn {
  min-height: 42px;
  padding: 0 12px;
  border-radius: 10px;
  background: transparent;
  color: #526076;
  font-weight: 600;
}

.tab-btn.active {
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 2px 10px rgba(24, 32, 45, 0.08);
}

.tab-panel {
  width: 100%;
  min-width: 0;
}

.section-head {
  margin-bottom: 12px;
}

.section-title {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 700;
}

.section-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.history-status {
  margin: 0;
  padding: 14px 0 2px;
  color: var(--muted);
  font-size: 14px;
}

.history-status.err {
  color: var(--err-text);
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid #e5ebf4;
}

.history-item:first-child {
  border-top: 0;
}

.history-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.history-date {
  font-size: 13px;
  color: var(--muted);
}

.history-range {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.history-delta {
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 700;
}

.history-delta.positive {
  color: #22623b;
}

.history-delta.negative {
  color: #9b2d2d;
}

.history-delta.neutral,
.history-delta.muted {
  color: var(--muted);
}

.message {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.message.ok {
  background: var(--ok-bg);
  border: 1px solid var(--ok-border);
  color: var(--ok-text);
}

.message.err {
  background: var(--err-bg);
  border: 1px solid var(--err-border);
  color: var(--err-text);
}

.message strong {
  display: block;
  margin-bottom: 6px;
}

@media (max-width: 520px) {
  .shell {
    width: 100vw;
    max-width: 100vw;
    padding: 10px 12px;
  }

  .card {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    border-radius: 14px;
    padding: 18px 14px;
  }

  h1 {
    font-size: 22px;
  }

  .time-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .user-bar {
    align-items: flex-start;
  }

  input {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0;
    padding-right: 10px;
  }

  .native-display {
    width: 100% !important;
    max-width: 100% !important;
    font-size: 16px;
  }

  .primary-btn,
  .native-field,
  .native-display,
  .field,
  .time-grid,
  form,
  .panel,
  .tab-panel,
  .history-list,
  .history-item {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  #timesheetForm > label,
  #timesheetForm > .native-field,
  #timesheetForm > .time-grid,
  #timesheetForm > button,
  .tab-bar,
  #historyPanel > .section-head,
  #historyPanel > .history-status,
  #historyPanel > .history-list {
    max-width: calc(100vw - 52px) !important;
  }

  .time-grid .field,
  .time-grid .field .native-field,
  .time-grid .field .native-display,
  .history-item {
    max-width: calc(100vw - 52px) !important;
  }

  .primary-btn {
    display: block;
    width: calc(100vw - 52px) !important;
    max-width: calc(100vw - 52px) !important;
    margin-right: 0;
  }

  .tab-btn {
    min-height: 40px;
  }

  .history-item {
    align-items: flex-start;
  }

  .history-delta {
    margin-top: 2px;
  }

  .icon-btn {
    margin-top: -4px;
  }
}
