:root {
  --bg: #eef3f0;
  --surface: #ffffff;
  --surface-soft: #f8faf8;
  --text: #232729;
  --muted: #5f6a66;
  --line: #c9d1cd;
  --green: #2f7d57;
  --green-hover: #3f9a6d;
  --green-dark: #256847;
  --danger: #9b2c2c;
  --danger-bg: #f8eeee;
  --warning: #755a16;
  --warning-bg: #fff7df;
  --info: #4f646f;
  --info-bg: #eef3f6;
  --radius: 8px;
  --shadow: 0 12px 30px rgba(35, 39, 41, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, #e4eee8 0%, var(--bg) 42%, #f6f8f6 100%);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

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

button {
  -webkit-tap-highlight-color: transparent;
  min-width: 0;
  font-size: 1rem;
  touch-action: manipulation;
}

.app-shell {
  width: 100%;
  max-width: 520px;
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.view {
  width: 100%;
}

.hidden {
  display: none !important;
  pointer-events: none !important;
}

.brand-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0 18px;
}

.brand-header.compact {
  margin: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: var(--radius);
  color: #ffffff;
  background: transparent;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: none;
}

.brand-mark img {
  display: block;
  width: 34px;
  height: 34px;
  object-fit: contain;
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.16;
}

h1 {
  font-size: clamp(1.65rem, 1.55rem + 0.6vw, 2rem);
}

h2 {
  margin-bottom: 14px;
  font-size: 1rem;
}

.card {
  margin-bottom: 14px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid rgba(201, 209, 205, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-view {
  display: grid;
  align-content: center;
  min-height: calc(100vh - 42px);
}

.login-card {
  padding: 20px;
}

.field {
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

.time-range-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.manual-project-form {
  display: grid;
  gap: 14px;
}

.manual-project-form .field {
  min-width: 0;
}

.manual-project-form .field,
.manual-project-form .time-range-grid,
.time-range-grid .field {
  margin-bottom: 0;
}

.manual-project-form input,
.manual-project-form select,
.manual-project-form textarea {
  display: block;
  width: 100%;
  inline-size: 100%;
  min-width: 0;
  min-inline-size: 0;
  max-width: 100%;
  max-inline-size: 100%;
}

.manual-project-form input[type="date"],
.manual-project-form input[type="time"] {
  -webkit-appearance: none;
  appearance: none;
}

.manual-project-form .status-message {
  margin: 0;
}

label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 13px;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 125, 87, 0.16);
}

select:disabled {
  color: #85908b;
  background: #eef2ef;
}

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

.primary-button,
.action-button,
.ghost-button {
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 850;
  touch-action: manipulation;
}

.primary-button {
  width: 100%;
  min-height: 56px;
  padding: 15px 18px;
  color: #ffffff;
  background: var(--green);
  box-shadow: 0 10px 20px rgba(47, 125, 87, 0.2);
}

.primary-button:hover,
.action-button.success:hover {
  background: var(--green-hover);
}

.primary-button:active,
.action-button.success:active {
  background: var(--green-dark);
}

.primary-button:disabled,
.action-button:disabled,
.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  box-shadow: none;
}

.app-header {
  display: grid;
  gap: 12px;
  margin: 8px 0 16px;
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.user-chip {
  min-width: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.user-chip strong {
  color: var(--text);
  overflow-wrap: anywhere;
}

.ghost-button {
  min-height: 48px;
  padding: 11px 14px;
  color: var(--green-dark);
  background: #e8f2ec;
  border: 1px solid #c5dfce;
}

.status-message {
  margin: 0 0 14px;
  padding: 12px 13px;
  color: var(--info);
  background: var(--info-bg);
  border: 1px solid #ccd7dd;
  border-radius: var(--radius);
  font-size: 0.92rem;
  font-weight: 700;
}

.status-message.error {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: #e0b7b7;
}

.status-message.warning {
  color: var(--warning);
  background: var(--warning-bg);
  border-color: #e5c56c;
}

.status-message.success {
  color: var(--green-dark);
  background: #e7f4ec;
  border-color: #b7dcc4;
}

.status-card {
  background: #fbfdfb;
}

.status-grid {
  display: grid;
  gap: 10px;
}

.status-grid > div {
  padding: 13px;
  background: var(--surface);
  border: 1px solid #dde5e0;
  border-radius: var(--radius);
}

.status-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.status-grid strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 1rem;
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.attendance-actions {
  margin-bottom: 14px;
}

.action-button {
  width: 100%;
  min-height: 58px;
  padding: 16px 18px;
  color: #ffffff;
  font-size: 1rem;
  box-shadow: 0 10px 20px rgba(35, 39, 41, 0.1);
}

.action-button.success {
  background: var(--green);
}

.action-button.neutral {
  color: var(--text);
  background: #dfe7e2;
}

.action-button.neutral:hover {
  background: #d3ded7;
}

.action-button.danger {
  background: var(--danger);
}

.action-button.danger:hover {
  background: #b14444;
}

.section-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.section-title-row h2 {
  margin-bottom: 0;
}

.entries-summary {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.entries-list {
  display: grid;
  gap: 10px;
}

.days-list {
  display: grid;
  gap: 10px;
}

.day-item {
  width: 100%;
  padding: 13px;
  color: var(--text);
  text-align: left;
  background: var(--surface-soft);
  border: 1px solid #dde5e0;
  border-radius: var(--radius);
  cursor: pointer;
}

.day-item.selected {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 125, 87, 0.12);
}

.day-item-header,
.day-metrics {
  display: grid;
  gap: 8px;
}

.day-item-header {
  grid-template-columns: 1fr auto;
  align-items: start;
  margin-bottom: 10px;
}

.day-item-header strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.day-metrics {
  grid-template-columns: 1fr 1fr;
}

.day-metrics > div {
  min-width: 0;
}

.day-metrics strong {
  display: block;
  font-size: 0.94rem;
  overflow-wrap: anywhere;
}

.correction-status {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  white-space: nowrap;
}

.correction-status.open {
  color: var(--warning);
}

.correction-status.applied {
  color: var(--green-dark);
}

.correction-status.rejected {
  color: var(--danger);
}

.correction-comparison {
  grid-column: 1 / -1;
  display: grid;
  gap: 9px;
  margin-top: 10px;
  padding: 10px;
  text-align: left;
  background: #fff8e1;
  border: 1px solid #eadca8;
  border-radius: var(--radius);
}

.correction-comparison-title {
  color: var(--warning);
  font-size: 0.86rem;
}

.correction-value-grid {
  display: grid;
  gap: 8px;
}

.correction-value-set {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.correction-value-set > strong {
  color: var(--text);
  font-size: 0.84rem;
}

.correction-value-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.correction-value-row b {
  color: var(--text);
  font-weight: 850;
  text-align: right;
}

.correction-reason {
  margin: 0;
  color: var(--text);
  font-size: 0.84rem;
}

.entry-item {
  padding: 13px;
  background: var(--surface-soft);
  border: 1px solid #dde5e0;
  border-radius: var(--radius);
}

.entry-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.entry-header strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.entry-duration {
  flex: 0 0 auto;
  color: var(--green-dark);
  font-size: 0.88rem;
  font-weight: 850;
}

.entry-meta,
.entry-detail,
.entry-note,
.empty-state {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.entry-note {
  color: var(--text);
}

.empty-state {
  margin-top: 0;
}

.detail-section {
  margin-top: 16px;
}

.detail-section h3 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.2;
}

.readonly-value {
  min-height: 44px;
  margin: 0;
  padding: 12px 13px;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-weight: 750;
}

.correction-form {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #dde5e0;
}

.correction-originals {
  margin-bottom: 14px;
  padding: 12px;
  background: #f3f7f4;
  border: 1px solid #dde5e0;
  border-radius: var(--radius);
}

.correction-originals-title {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
}

.correction-original-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.correction-original-grid strong {
  display: block;
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

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

.correction-original-entry {
  display: grid;
  gap: 3px;
  padding: 9px 0;
  border-top: 1px solid #dde5e0;
}

.correction-original-entry:first-child {
  padding-top: 0;
  border-top: 0;
}

.correction-original-entry strong {
  overflow-wrap: anywhere;
}

.correction-original-entry span {
  color: var(--muted);
  font-size: 0.88rem;
}

.correction-field-group {
  margin-bottom: 14px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  align-items: end;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  background: rgba(35, 39, 41, 0.42);
  pointer-events: auto;
}

.modal-backdrop.hidden {
  display: none !important;
  pointer-events: none;
}

.modal-dialog {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 18px;
  background: var(--surface);
  border: 1px solid rgba(201, 209, 205, 0.95);
  border-radius: var(--radius);
  box-shadow: 0 18px 45px rgba(35, 39, 41, 0.24);
}

.summary-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.summary-grid > div {
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid #dde5e0;
  border-radius: var(--radius);
}

.summary-grid strong {
  display: block;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.modal-actions .primary-button {
  min-height: 56px;
}

.modal-actions .ghost-button,
.modal-actions .primary-button {
  width: 100%;
}

@media (max-width: 430px) {
  .user-row,
  .section-title-row {
    align-items: stretch;
    flex-direction: column;
  }

  .user-row .ghost-button,
  .section-title-row .ghost-button,
  .action-grid .action-button {
    width: 100%;
  }
}

@media (max-width: 380px) {
  .app-shell {
    padding-right: 12px;
    padding-left: 12px;
  }

  .card {
    padding: 14px;
  }
}

@media (min-width: 431px) {
  .app-shell {
    padding-right: 20px;
    padding-left: 20px;
  }

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

  .modal-actions {
    grid-template-columns: 1fr 1fr;
  }

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

  .correction-value-grid {
    grid-template-columns: 1fr 1fr;
  }
}
