:root {
  --ink: #17313b;
  --ink-soft: #566e77;
  --navy: #0b3b4a;
  --navy-2: #0d4d59;
  --teal: #0aa184;
  --teal-dark: #07816b;
  --teal-soft: #dcf5ef;
  --sand: #f5f3ed;
  --paper: #ffffff;
  --line: #dfe7e8;
  --amber: #eea726;
  --amber-soft: #fff0cf;
  --red: #c8473d;
  --red-soft: #fde7e4;
  --blue: #3478b8;
  --blue-soft: #e7f1fb;
  --shadow: 0 14px 40px rgba(13, 54, 63, .09);
  --radius: 18px;
  font-family: Inter, "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", sans-serif;
  color: var(--ink);
  background: var(--sand);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--sand); }
body { min-height: 100vh; margin: 0; background: var(--sand); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--ink-soft); }
.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
}
.required { margin-left: 7px; color: var(--red); font-size: 11px; }
.hint { margin-left: 7px; color: #82959b; font-size: 11px; }

.login-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 1.1fr) minmax(360px, .9fr);
  background: var(--paper);
}
.login-visual {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(48px, 8vw, 120px);
  color: #fff;
  background:
    radial-gradient(circle at 80% 15%, rgba(43, 206, 169, .24), transparent 28%),
    linear-gradient(145deg, #082f3c, #0b4d57 60%, #0f6d62);
}
.login-visual::after {
  content: "";
  position: absolute;
  right: -80px;
  bottom: -130px;
  width: 420px;
  height: 420px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 50%;
  box-shadow: 0 0 0 56px rgba(255,255,255,.035), 0 0 0 112px rgba(255,255,255,.025);
}
.login-visual h1 { margin: 18px 0; font-size: clamp(38px, 5vw, 68px); line-height: 1.18; letter-spacing: -.04em; }
.login-visual > p:last-child { max-width: 580px; font-size: 17px; line-height: 1.9; color: rgba(255,255,255,.75); }
.login-card {
  width: min(430px, calc(100% - 48px));
  align-self: center;
  justify-self: center;
  display: grid;
  gap: 22px;
  padding: 40px;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.login-card h2 { margin: 0; font-size: 32px; }
.login-card p { margin: 5px 0 0; }

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  font-weight: 900;
  background: linear-gradient(145deg, var(--teal), #37c7a8);
  box-shadow: 0 7px 18px rgba(10, 161, 132, .22);
}
.brand-mark-large { width: 58px; height: 58px; border-radius: 16px; font-size: 24px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 26px 18px;
  color: #fff;
  background: var(--navy);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 30px; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 17px; }
.brand span { margin-top: 3px; color: rgba(255,255,255,.55); font-size: 11px; }
.side-nav { display: grid; gap: 7px; }
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 15px;
  border: 0;
  border-radius: 12px;
  color: rgba(255,255,255,.66);
  background: transparent;
  text-align: left;
  transition: .18s ease;
}
.nav-item span { width: 20px; color: #60d4bb; font-size: 18px; text-align: center; }
.nav-item:hover, .nav-item.active { color: #fff; background: rgba(255,255,255,.09); }
.sidebar-footer {
  margin-top: auto;
  padding: 18px 10px 0;
  border-top: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.7);
  font-size: 13px;
}
.text-button { margin-top: 5px; padding: 0; border: 0; color: #69d8bf; background: none; font-size: 12px; }

.content-shell { min-width: 0; }
.topbar {
  min-height: 98px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(22px, 4vw, 54px);
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.75);
  backdrop-filter: blur(14px);
}
.topbar h1 { margin: 0; font-size: 25px; letter-spacing: -.025em; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 9px; padding-left: 8px; }
.user-chip > span {
  display: grid; width: 36px; height: 36px; place-items: center;
  border-radius: 50%; color: var(--navy); font-weight: 800; background: var(--teal-soft);
}
.user-chip strong, .user-chip small { display: block; }
.user-chip strong { font-size: 12px; }
.user-chip small { color: var(--ink-soft); font-size: 10px; }
#main { max-width: 1580px; margin: 0 auto; padding: 34px clamp(20px, 4vw, 54px) 70px; outline: none; }
.bottom-nav { display: none; }

.button, .icon-button {
  border: 0;
  border-radius: 11px;
  font-weight: 700;
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
}
.button { min-height: 43px; padding: 10px 17px; }
.button:hover, .icon-button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .55; transform: none; }
.button-primary { color: #fff; background: var(--teal); box-shadow: 0 8px 18px rgba(10,161,132,.18); }
.button-primary:hover { background: var(--teal-dark); }
.button-secondary { color: var(--ink); border: 1px solid var(--line); background: #fff; }
.button-danger { color: var(--red); background: var(--red-soft); }
.button-wide { width: 100%; }
.button-small { min-height: 34px; padding: 7px 11px; font-size: 12px; }
.icon-button {
  display: grid; width: 42px; height: 42px; place-items: center;
  color: var(--ink); border: 1px solid var(--line); background: #fff; font-size: 19px;
}

label { display: grid; gap: 7px; color: var(--ink); font-size: 13px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #cfdadd;
  border-radius: 10px;
  outline: none;
  color: var(--ink);
  background: #fff;
  transition: border .15s, box-shadow .15s;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(10,161,132,.13); }
.form-error { min-height: 18px; margin: 0; color: var(--red); font-size: 13px; }

.page-tools {
  display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 24px;
}
.page-tools h2 { margin: 0; font-size: 20px; }
.tool-group { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; }
.tool-group label { min-width: 150px; }
.month-picker { width: 160px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 28px; }
.metric-card, .panel {
  border: 1px solid rgba(214,225,226,.92);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 6px 24px rgba(21,62,69,.04);
}
.metric-card { position: relative; overflow: hidden; padding: 21px; }
.metric-card::after {
  content: ""; position: absolute; right: -22px; top: -24px; width: 84px; height: 84px;
  border-radius: 50%; background: var(--teal-soft);
}
.metric-card:nth-child(2)::after { background: var(--blue-soft); }
.metric-card:nth-child(3)::after { background: var(--amber-soft); }
.metric-card:nth-child(4)::after { background: #edf0f6; }
.metric-card span { color: var(--ink-soft); font-size: 12px; font-weight: 700; }
.metric-card strong { display: block; margin-top: 10px; font-size: clamp(25px, 2.4vw, 35px); letter-spacing: -.035em; }
.metric-card small { color: var(--ink-soft); font-size: 11px; }
.metric-card.alert strong { color: var(--amber); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(310px, .7fr); gap: 20px; }
.panel { padding: 23px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.panel-header h2, .panel-header h3 { margin: 0; font-size: 17px; }
.panel-header p { margin: 4px 0 0; color: var(--ink-soft); font-size: 12px; }

.yard-list { display: grid; gap: 10px; }
.yard-row {
  display: grid; grid-template-columns: minmax(100px, 1.25fr) minmax(130px, 1.3fr) repeat(3, minmax(72px, .7fr));
  align-items: center; gap: 14px; padding: 13px 6px; border-top: 1px solid #edf1f2;
}
.yard-row.header { padding-top: 0; border: 0; color: var(--ink-soft); font-size: 11px; font-weight: 800; }
.yard-name strong, .yard-name small { display: block; }
.yard-name small { margin-top: 3px; color: var(--ink-soft); font-size: 11px; }
.yard-value { text-align: right; }
.yard-value strong, .yard-value small { display: block; }
.yard-value small { color: var(--ink-soft); font-size: 10px; }
progress { width: 100%; height: 8px; border: 0; border-radius: 9px; overflow: hidden; background: #edf2f2; }
progress::-webkit-progress-bar { background: #edf2f2; border-radius: 9px; }
progress::-webkit-progress-value { background: linear-gradient(90deg, var(--teal), #42c9aa); border-radius: 9px; }
progress::-moz-progress-bar { background: var(--teal); border-radius: 9px; }
.progress-label { display: flex; justify-content: space-between; margin-top: 5px; color: var(--ink-soft); font-size: 10px; }

.upcoming-list { display: grid; gap: 11px; }
.upcoming-item, .list-card {
  width: 100%; display: grid; gap: 8px; padding: 15px; border: 1px solid var(--line);
  border-radius: 13px; color: var(--ink); background: #fff; text-align: left;
}
.upcoming-item:hover, .list-card:hover { border-color: #a8c8c4; box-shadow: 0 8px 20px rgba(17,70,76,.07); }
.date-chip { color: var(--teal-dark); font-size: 11px; font-weight: 800; }
.item-title { font-size: 14px; font-weight: 800; }
.item-meta { color: var(--ink-soft); font-size: 11px; }
.badge {
  width: max-content; display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 20px;
  font-size: 10px; font-weight: 800; background: #edf1f3; color: var(--ink-soft);
}
.badge-planned { color: #9c6812; background: var(--amber-soft); }
.badge-acknowledged { color: #22679e; background: var(--blue-soft); }
.badge-in_storage { color: var(--teal-dark); background: var(--teal-soft); }
.badge-completed { color: #5f6e73; background: #edf1f3; }
.badge-cancelled { color: var(--red); background: var(--red-soft); }
.empty-state { padding: 42px 20px; color: var(--ink-soft); text-align: center; }
.empty-state strong { display: block; margin-bottom: 6px; color: var(--ink); }

.calendar-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; }
.calendar { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.calendar-weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.calendar-weekdays div { padding: 11px 6px; color: var(--ink-soft); background: #f8faf9; font-size: 11px; font-weight: 800; text-align: center; }
.calendar-day { min-height: 118px; padding: 9px; border-top: 1px solid var(--line); border-right: 1px solid var(--line); background: #fff; }
.calendar-day:nth-child(7n) { border-right: 0; }
.calendar-day.outside { background: #f8f8f6; color: #a2adb0; }
.calendar-day.today .day-number { display: grid; width: 25px; height: 25px; place-items: center; border-radius: 50%; color: #fff; background: var(--teal); }
.day-number { display: block; margin-bottom: 6px; font-size: 11px; font-weight: 800; }
.calendar-event {
  width: 100%; display: block; margin: 4px 0; padding: 5px 7px; overflow: hidden;
  border: 0; border-left: 3px solid var(--teal); border-radius: 5px;
  color: var(--navy); background: var(--teal-soft); font-size: 10px; font-weight: 700; text-align: left; white-space: nowrap; text-overflow: ellipsis;
}
.calendar-event.departure { border-left-color: var(--blue); background: var(--blue-soft); }
.more-events { color: var(--ink-soft); font-size: 9px; }

.filter-panel { display: grid; grid-template-columns: 1.5fr repeat(4, minmax(120px, .7fr)) auto; gap: 10px; align-items: end; margin-bottom: 18px; }
.filter-panel label { min-width: 0; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th { position: sticky; top: 0; z-index: 1; padding: 12px; color: var(--ink-soft); background: #f7f9f8; text-align: left; white-space: nowrap; }
.data-table td { padding: 13px 12px; border-top: 1px solid #edf1f2; vertical-align: top; }
.data-table tbody tr { cursor: pointer; }
.data-table tbody tr:hover { background: #fbfdfc; }
.nowrap { white-space: nowrap; }
.table-primary { display: block; font-weight: 800; }
.table-secondary { display: block; margin-top: 3px; color: var(--ink-soft); font-size: 10px; }
.pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 15px; color: var(--ink-soft); font-size: 12px; }

.storage-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.storage-card { position: relative; }
.storage-card .badge { position: absolute; top: 14px; right: 14px; }
.storage-card h3 { margin: 4px 70px 5px 0; font-size: 16px; }
.storage-card dl { display: grid; grid-template-columns: 80px 1fr; gap: 7px 10px; margin: 14px 0 0; font-size: 12px; }
.storage-card dt { color: var(--ink-soft); }
.storage-card dd { margin: 0; font-weight: 700; }

.modal { width: min(760px, calc(100% - 26px)); max-height: calc(100vh - 30px); padding: 0; border: 0; border-radius: 21px; background: transparent; box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(6, 34, 43, .55); backdrop-filter: blur(3px); }
.modal-panel { max-height: calc(100vh - 30px); overflow: auto; padding: 26px; border-radius: 21px; background: #fff; }
.modal-header { position: sticky; top: -26px; z-index: 3; display: flex; justify-content: space-between; align-items: center; gap: 18px; margin: -1px -1px 22px; padding: 2px 1px 13px; background: #fff; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 21px; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 17px 14px; }
.span-2 { grid-column: span 2; }
.span-full { grid-column: 1 / -1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 17px; border-top: 1px solid var(--line); }
.detail-panel { width: 100%; }
.detail-hero { display: flex; justify-content: space-between; gap: 18px; padding: 18px; border-radius: 15px; background: var(--sand); }
.detail-hero h3 { margin: 6px 0 2px; font-size: 21px; }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 18px 0; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: var(--line); }
.detail-cell { min-height: 76px; padding: 13px; background: #fff; }
.detail-cell span, .detail-section > span { display: block; margin-bottom: 5px; color: var(--ink-soft); font-size: 10px; font-weight: 800; }
.detail-cell strong { font-size: 13px; }
.detail-section { margin-top: 12px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; white-space: pre-wrap; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.worker-note { width: 100%; margin-top: 12px; }
.timeline { display: grid; gap: 0; margin-top: 20px; }
.timeline h3 { margin: 0 0 12px; font-size: 15px; }
.timeline-item { position: relative; padding: 0 0 16px 23px; border-left: 2px solid var(--line); }
.timeline-item::before { content: ""; position: absolute; left: -6px; top: 2px; width: 10px; height: 10px; border-radius: 50%; background: var(--teal); }
.timeline-item strong, .timeline-item span { display: block; font-size: 11px; }
.timeline-item span { margin-top: 3px; color: var(--ink-soft); }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.stack { display: grid; gap: 14px; }
.file-drop { padding: 18px; border: 1px dashed #a8c2c2; border-radius: 12px; background: #f9fbfa; }
.file-drop input { margin-top: 8px; padding: 7px; background: #fff; }
.user-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.user-row:first-child { border-top: 0; }
.user-row strong, .user-row span { display: block; }
.user-row span { color: var(--ink-soft); font-size: 11px; }
.import-result { padding: 12px; border-radius: 10px; color: var(--teal-dark); background: var(--teal-soft); font-size: 12px; }

.skeleton { position: relative; overflow: hidden; min-height: 110px; background: #e9eeee; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.65), transparent); animation: loading 1.35s infinite; }
@keyframes loading { to { transform: translateX(100%); } }
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 10px; }
.toast { max-width: 360px; padding: 13px 16px; border-radius: 12px; color: #fff; background: var(--navy); box-shadow: var(--shadow); font-size: 13px; animation: toast-in .22s ease; }
.toast.error { background: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

@media (max-width: 1150px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid, .calendar-layout { grid-template-columns: 1fr; }
  .storage-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-panel { grid-template-columns: repeat(3, 1fr); }
  .filter-panel .search-field { grid-column: span 2; }
}

@media (max-width: 760px) {
  .login-view { grid-template-columns: 1fr; background: linear-gradient(160deg, #083541, #0d665d); }
  .login-visual { min-height: 265px; padding: 36px 28px 50px; background: transparent; }
  .login-visual h1 { font-size: 32px; }
  .login-visual > p:last-child { margin-bottom: 0; font-size: 13px; }
  .login-card { position: relative; margin-top: -25px; margin-bottom: 30px; padding: 28px; background: #fff; }
  .app-shell { display: block; }
  .sidebar { display: none; }
  .content-shell { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .topbar { position: sticky; top: 0; z-index: 20; min-height: 72px; padding: 11px 16px; }
  .topbar h1 { font-size: 19px; }
  .topbar .eyebrow, .user-chip, #refresh-button { display: none; }
  #add-job-button { width: 42px; min-height: 42px; padding: 0; font-size: 0; }
  #add-job-button span { font-size: 25px; }
  #main { padding: 22px 14px 40px; }
  .bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: flex; justify-content: space-around;
    padding: 7px 5px calc(7px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(12px);
  }
  .bottom-nav button { display: grid; gap: 2px; place-items: center; min-width: 55px; padding: 4px; border: 0; color: #819399; background: transparent; font-size: 9px; }
  .bottom-nav button span { font-size: 19px; }
  .bottom-nav button.active { color: var(--teal-dark); font-weight: 800; }
  .page-tools { align-items: stretch; flex-direction: column; }
  .tool-group { display: grid; grid-template-columns: 1fr 1fr; }
  .tool-group label, .month-picker { width: 100%; min-width: 0; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 18px; }
  .metric-card { padding: 16px; border-radius: 14px; }
  .metric-card strong { font-size: 24px; }
  .panel { padding: 17px; }
  .yard-row { grid-template-columns: 1.1fr 1fr 1fr; gap: 8px; }
  .yard-row.header > :nth-child(2), .yard-row > :nth-child(2), .yard-row.header > :nth-child(5), .yard-row > :nth-child(5) { display: none; }
  .yard-value strong { font-size: 12px; }
  .calendar-weekdays div { padding: 8px 1px; font-size: 9px; }
  .calendar-day { min-height: 82px; padding: 4px; }
  .calendar-event { padding: 4px; font-size: 8px; }
  .calendar-month-nav { display: grid; grid-template-columns: 42px 1fr 42px; align-items: center; }
  .calendar-month-nav > div { text-align: center; }
  .filter-panel { grid-template-columns: 1fr 1fr; }
  .filter-panel .search-field { grid-column: 1 / -1; }
  .table-wrap { border-radius: 12px; }
  .data-table th, .data-table td { padding: 11px 9px; }
  .data-table th:nth-child(4), .data-table td:nth-child(4), .data-table th:nth-child(5), .data-table td:nth-child(5), .data-table th:nth-child(6), .data-table td:nth-child(6) { display: none; }
  .storage-grid { grid-template-columns: 1fr; }
  .modal { width: 100%; max-height: 94vh; margin: auto 0 0; border-radius: 22px 22px 0 0; }
  .modal-panel { max-height: 94vh; padding: 21px 16px calc(20px + env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0; }
  .modal-header { top: -21px; margin-bottom: 18px; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .span-2, .form-grid .span-full { grid-column: 1 / -1; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .toast-region { left: 14px; right: 14px; bottom: 82px; }
  .toast { max-width: none; }
}

@media (max-width: 410px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid label { grid-column: 1 / -1; }
}

@media (max-width: 340px) {
  .metric-grid { grid-template-columns: 1fr; }
}
