/* FieldOps — AIRecruit360-inspired design tokens */
:root {
  --primary-50: #EFF7FF;
  --primary-100: #DCEEFF;
  --primary-500: #0271E4;
  --primary-600: #0067D1;
  --primary-700: #0058B5;

  --bg: #FAFAFA;
  --card: #FFFFFF;
  --ink: #111111;
  --ink-secondary: #555555;
  --muted: #777777;
  --accent: #0271E4;
  --line: #E5E5E5;
  --line-subtle: #EEEEEE;
  --danger: #D83B3B;
  --danger-bg: #FCE4E4;
  --danger-text: #B32626;
  --ok: #23863A;
  --ok-bg: #DDF8E3;
  --info-bg: #E6F2FF;
  --info-text: #0266CB;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 20px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--primary-600); text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  background: var(--card);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.brand {
  font-weight: 600;
  letter-spacing: -0.02em;
  font-size: 1.15rem;
  color: var(--ink);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.nav a {
  color: #444444;
  font-size: 14px;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-pill);
  text-decoration: none;
}

.nav a:hover {
  background: #F5F8FC;
  color: #222222;
  text-decoration: none;
}

.nav a.active {
  background: var(--accent);
  color: #fff;
}

.nav a.active:hover {
  background: var(--primary-600);
  color: #fff;
  text-decoration: none;
}

.nav .btn-link {
  color: #444444;
  font-size: 14px;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-pill);
}

.nav .btn-link:hover {
  background: #F5F8FC;
  color: #222222;
  text-decoration: none;
}

.container {
  max-width: 1100px;
  margin: 1.4rem auto;
  padding: 0 1rem 2rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow-sm);
}

h1, h2, h3 {
  margin-top: 0;
  color: var(--ink);
  letter-spacing: -0.01em;
}

h1 {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.25;
}

h3 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  font-size: 14px;
  border: 1px solid transparent;
}

.flash-ok {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: #C6EFD0;
}

.flash-error {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: #F5C8C8;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th, .table td {
  text-align: left;
  padding: 0.75rem 0.65rem;
  border-bottom: 1px solid var(--line-subtle);
  vertical-align: top;
}

.table th {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.table td {
  font-size: 14px;
  font-weight: 500;
  color: #222222;
}

.table .col-comment {
  max-width: 18rem;
  word-break: break-word;
}

.table.hide-comment .col-comment {
  display: none;
}

.stock-inline-form {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  align-items: center;
}

.stock-inline-form input[type="number"],
.stock-inline-form input[name="comment"] {
  width: auto;
  min-width: 0;
}

.stock-inline-form input[type="number"] {
  flex: 0 0 5.5rem;
  width: 5.5rem;
}

.stock-inline-form input[name="comment"] {
  flex: 1 1 7rem;
  width: 7rem;
  min-width: 5rem;
}

.stock-inline-form .btn {
  flex: 0 0 auto;
}

.stock-inline-form select {
  width: auto;
  max-width: 7.5rem;
  padding: 0.35rem 2rem 0.35rem 0.4rem;
  background-position: right 0.45rem center;
}

.col-actions {
  width: 3rem;
  text-align: right;
  white-space: nowrap;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-secondary);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-icon:hover {
  background: var(--primary-50);
  border-color: var(--primary-100);
  color: var(--primary-600);
  text-decoration: none;
}

.btn-icon:active {
  background: var(--primary-100);
}

.adjust-form .actions {
  margin-top: 1rem;
}

.address-panel .muted {
  margin-top: 0;
  margin-bottom: 1.1rem;
}

.address-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.address-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem 1rem;
  align-items: end;
  padding: 0.9rem 1rem;
  background: var(--bg);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius-md);
}

.address-edit-form {
  min-width: 0;
}

.address-item .form-grid {
  margin-bottom: 0;
}

.address-item-actions {
  margin-top: 0.45rem;
}

.address-delete-form {
  padding-bottom: 0.15rem;
}

.address-add {
  padding-top: 0.15rem;
}

.address-add-title {
  margin: 0 0 0.75rem;
  padding-top: 1rem;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-secondary);
  border-top: 1px solid var(--line-subtle);
}

.address-add .actions {
  margin-top: 1rem;
}

.address-panel .form-grid input::placeholder {
  color: #AAAAAA;
}

.column-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.25rem;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-secondary);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.column-toggle input {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius-pill);
  padding: 0.55rem 1.1rem;
  min-height: 40px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  box-shadow: 0 2px 6px rgba(2, 113, 228, 0.15);
}

.btn:hover {
  background: var(--primary-600);
  border-color: var(--primary-600);
  text-decoration: none;
  color: #fff;
}

.btn:active {
  background: var(--primary-700);
  border-color: var(--primary-700);
  box-shadow: none;
}

.btn-secondary {
  background: #F5F5F5;
  color: #333333;
  border-color: #E5E5E5;
  box-shadow: none;
}

.btn-secondary:hover {
  background: #EEEEEE;
  border-color: #DCDCDC;
  color: #333333;
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  box-shadow: 0 2px 6px rgba(216, 59, 59, 0.15);
}

.btn-danger:hover {
  background: #C23232;
  border-color: #C23232;
  color: #fff;
}

.btn-link {
  background: transparent;
  color: var(--accent);
  padding: 0;
  border: none;
  border-radius: 0;
  min-height: 0;
  box-shadow: none;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
}

.btn-link:hover {
  color: var(--primary-600);
  text-decoration: underline;
  background: transparent;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-secondary);
  margin-bottom: 0.3rem;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="hidden"]):not([type="image"]):not([type="reset"]):not([type="file"]),
select,
textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font: inherit;
  font-size: 14px;
  line-height: 20px;
  color: #333333;
  background: #fff;
  min-height: 40px;
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 2.25rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  cursor: pointer;
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  line-height: 1;
  accent-color: var(--accent);
  vertical-align: middle;
  cursor: pointer;
}

input::placeholder,
textarea::placeholder {
  color: #999999;
  opacity: 1;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="hidden"]):not([type="image"]):not([type="reset"]):not([type="file"]):hover,
select:hover,
textarea:hover {
  border-color: #D5D5D5;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="hidden"]):not([type="image"]):not([type="reset"]):not([type="file"]):focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(2, 113, 228, 0.10);
}

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

input.is-invalid,
select.is-invalid,
textarea.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(216, 59, 59, 0.12);
}

input.is-invalid:focus,
select.is-invalid:focus,
textarea.is-invalid:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(216, 59, 59, 0.12);
}

.field-validity-tip {
  position: fixed;
  z-index: 2000;
  max-width: min(280px, calc(100vw - 1.5rem));
  padding: 0.55rem 0.8rem;
  background: var(--card);
  color: var(--danger-text);
  border: 1px solid #F5C8C8;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  pointer-events: none;
}

.field-validity-tip::before {
  content: "";
  position: absolute;
  top: -5px;
  left: var(--arrow-left, 14px);
  width: 8px;
  height: 8px;
  background: var(--card);
  border-left: 1px solid #F5C8C8;
  border-top: 1px solid #F5C8C8;
  transform: rotate(45deg);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.muted { color: var(--muted); }

.login-wrap {
  max-width: 420px;
  margin: 4rem auto;
}

.container-wide { max-width: 1280px; }

.home-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1rem;
}

.note-add { display: flex; gap: 0.4rem; }
.note-list { list-style: none; padding: 0; margin: 1rem 0 0; }
.note-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line-subtle);
}
.note-list li.done span { text-decoration: line-through; color: var(--muted); }

tr.overdue { background: var(--danger-bg); }
.badge-overdue, .badge-priority {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--danger-bg);
  color: var(--danger-text);
}
.badge-priority {
  background: var(--info-bg);
  color: var(--info-text);
}
.priority-row { background: var(--primary-50); }

.qty-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 0 12px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
}

.qty-pill.qty-in {
  background: var(--ok-bg);
  color: var(--ok);
}

.qty-pill.qty-out {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 1rem 0; }
.tabs a {
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-pill);
  background: #F5F5F5;
  color: #333333;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid #E5E5E5;
  text-decoration: none;
}
.tabs a:hover {
  background: #EEEEEE;
  text-decoration: none;
}
.tabs a.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.search-row { display: flex; gap: 0.5rem; margin-bottom: 1rem; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 17, 17, 0.28);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  z-index: 20;
  overflow: auto;
}
.overlay.hidden { display: none; }
.day-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.35rem;
  width: min(1100px, 100%);
  box-shadow: var(--shadow-md);
}
.day-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}
#dayMap {
  min-height: 360px;
  border-radius: 12px;
  border: 1px solid var(--line);
}
.day-event {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem;
  margin-bottom: 0.6rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}
.detail-card { width: min(640px, 100%); }

#calendar {
  min-height: 650px;
}

@media (max-width: 900px) {
  .home-grid, .day-grid { grid-template-columns: 1fr; }
}

.material-row {
  display: grid;
  grid-template-columns: 2fr 1fr auto;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  align-items: end;
}

@media print {
  .topbar, .no-print { display: none !important; }
  body { background: #fff; }
  .container { margin: 0; max-width: none; }
  .card { box-shadow: none; border: none; }
}
