:root {
  --accent: #ff8a00;
  --accent-2: #ff6a00;
  --accent-soft: #fff4e6;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-muted: #fafafa;
  --border: #e7e9ee;
  --text: #101217;
  --muted: #6b7280;
  --danger: #ef4444;
  --ok: #10b981;
  --shadow-sm: 0 6px 16px rgba(16, 18, 23, 0.06);
  --shadow-md: 0 10px 30px rgba(16, 18, 23, 0.08);
  --radius-xl: 20px;
  --radius: 12px;
  --focus: rgba(255, 138, 0, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.auth-page {
  min-height: 100vh;
}

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
}

.auth-card {
  width: 100%;
  max-width: 540px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.auth-card-wide {
  max-width: 920px;
}

.auth-logo {
  display: block;
  width: 96px;
  height: 96px;
  margin: 8px auto 4px;
  border-radius: 24px;
  object-fit: cover;
}

.auth-card h1 {
  margin: 10px 0 6px;
  text-align: center;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0;
}

.auth-subtitle {
  margin: 0;
  color: var(--muted);
  text-align: center;
  font-size: 0.97rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 18px;
}

.label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #3c4350;
  font-size: 0.86rem;
  font-weight: 700;
}

.input,
.field input,
.field select,
.inline-row input,
.inline-row select,
#customer_select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  outline: none;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.field input,
.field select,
.inline-row input,
.inline-row select,
#customer_select {
  padding: 11px 13px;
}

.input {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
}

.input svg {
  flex: 0 0 auto;
  color: #9aa1ad;
}

.input input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
}

.input:focus-within,
.field input:focus,
.field select:focus,
.inline-row input:focus,
.inline-row select:focus,
#customer_select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--focus);
}

.form-error {
  min-height: 1.2rem;
  color: var(--danger);
  text-align: center;
  font-size: 0.94rem;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.check-row input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 15px;
  border: 1px solid transparent;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 800;
  text-decoration: none;
  transition: transform 0.04s ease, filter 0.2s ease, background 0.2s ease, border 0.2s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  filter: brightness(1.03);
}

.btn-outline {
  border-color: rgba(255, 138, 0, 0.55);
  background: #fff;
  color: var(--accent);
}

.btn-outline:hover {
  background: #fff7ef;
}

.btn-ghost {
  border-color: var(--border);
  background: var(--surface);
  color: var(--muted);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-full {
  width: 100%;
  margin-top: 6px;
}

.link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.link:hover {
  text-decoration: underline;
}

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

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

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

.form-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.span-2 {
  grid-column: span 2;
}

.section-title {
  margin: 18px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  color: #8a4a05;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.app-page {
  padding-bottom: 86px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
}

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

.brand img {
  width: 42px;
  height: 42px;
  border-radius: 12px;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 1rem;
}

.brand span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
}

.app-wrap {
  width: min(1040px, calc(100vw - 28px));
  margin: 24px auto;
}

.tabs {
  display: flex;
  gap: 4px;
  align-items: flex-end;
}

.tab {
  min-height: 42px;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  background: #eceef3;
  color: #555d6b;
  font-size: 0.88rem;
  font-weight: 800;
}

.tab.is-active {
  background: var(--surface);
  color: var(--accent-2);
  box-shadow: 0 -1px 6px rgba(16, 18, 23, 0.04);
}

.panel {
  display: none;
  padding: 24px 26px 28px;
  border: 1px solid var(--border);
  border-radius: 0 16px 16px 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.panel.is-active {
  display: block;
}

.inline-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.inline-row-short input {
  max-width: 210px;
}

.logo-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  max-width: 520px;
}

.sequence-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: center;
}

.sequence-row input {
  color: var(--text);
  font-size: 1rem;
  font-weight: 900;
}

.seq-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--muted);
}

.seq-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #fff7ef;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
}

.items-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.85rem;
}

.items-table th,
.items-table td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.items-table th {
  background: #fff8f0;
  color: #7a3b00;
  font-weight: 900;
}

.items-table tr:last-child td {
  border-bottom: 0;
}

.items-table .right {
  text-align: right;
}

.empty-row td {
  color: #9aa1ad;
  text-align: center;
}

.row-delete {
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 0.78rem;
}

.total-line {
  margin-top: 14px;
  text-align: right;
  color: var(--muted);
}

.total-line strong {
  color: var(--text);
  font-size: 1.1rem;
}

.item-editor {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid #ffe2bf;
  border-radius: 14px;
  background: var(--accent-soft);
}

.item-grid {
  grid-template-columns: minmax(220px, 2fr) 0.8fr 0.7fr 1fr 0.8fr;
}

.item-actions {
  margin-top: 12px;
}

.action-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 28px;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -2px 10px rgba(16, 18, 23, 0.07);
  backdrop-filter: blur(10px);
}

.action-left {
  display: flex;
  gap: 8px;
}

.toast {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 100;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 15px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  color: var(--text);
  font-size: 0.9rem;
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.is-ok {
  border-color: rgba(16, 185, 129, 0.35);
}

.toast.is-error {
  border-color: rgba(239, 68, 68, 0.35);
}

@media (max-width: 780px) {
  .form-grid-2,
  .form-grid-3,
  .item-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .tabs {
    overflow-x: auto;
  }

  .tab {
    flex: 0 0 auto;
  }

  .panel {
    padding: 20px 16px 24px;
  }

  .inline-row,
  .logo-row,
  .action-bar,
  .action-left {
    flex-direction: column;
    align-items: stretch;
  }

  .inline-row-short input {
    max-width: none;
  }

  .app-header {
    padding: 12px 16px;
  }
}
