:root {
  --bg: #f6efe6; --panel: #ffffff; --ink: #2c2838; --muted: #6b6578; --line: #e9dfd2;
  --rose: #b0486b; --rose-soft: #f6dbe3; --blue: #2f6aa8; --blue-soft: #dcebf8;
  --green: #2a8a64; --green-soft: #dcf2e8; --amber: #a86a10; --amber-soft: #fbecd0;
  --violet: #5b4bd0; --violet-soft: #e6e2fb; --red: #c0392b; --red-soft: #fbe0dc;
  --serif: Georgia, "Times New Roman", serif; --sans: Arial, "Helvetica Neue", sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.5; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-family: var(--serif); }

/* login */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(900px 500px at 10% 0%, #f9d3de 0%, transparent 60%), radial-gradient(800px 500px at 100% 100%, #c9e1f5 0%, transparent 60%), var(--bg); }
.login { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 34px 30px; box-shadow: 0 30px 60px -36px rgba(80, 50, 70, .5); }
.brand { font-family: var(--serif); font-weight: bold; font-size: 28px; }
.brand span { color: var(--rose); }
.login h1 { font-size: 22px; margin: 18px 0 4px; }
.login p.sub { color: var(--muted); margin-bottom: 22px; font-size: 14px; }

/* forms */
label.f { display: block; margin-bottom: 14px; }
label.f > span { display: block; font-size: 12.5px; font-weight: bold; color: var(--muted); margin-bottom: 5px; letter-spacing: .3px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; background: #fff; border: 1px solid #d9cdbd; border-radius: 10px; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(47, 106, 168, .35); border-color: var(--blue); }
.form-error { color: var(--red); background: var(--red-soft); border-radius: 10px; padding: 9px 12px; margin-bottom: 14px; font-size: 14px; }
.form-error:empty { display: none; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; margin: 4px 0 14px; }

.btn { border: 1px solid #d9cdbd; background: #fff; border-radius: 10px; padding: 9px 16px; font-weight: bold; font-size: 14px; }
.btn:hover { background: #faf5ee; }
.btn.primary { background: var(--rose); border-color: var(--rose); color: #fff; }
.btn.primary:hover { background: #9b3d5c; }
.btn.danger { color: var(--red); border-color: #efc4be; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: default; }
.icon-btn { border: 0; background: transparent; font-size: 24px; line-height: 1; padding: 4px 8px; border-radius: 8px; color: var(--muted); }
.icon-btn:hover { background: #f1e8dc; }
.link { border: 0; background: none; color: var(--blue); padding: 0; font-weight: bold; }

/* shell */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100%; }
.side { background: #fffaf4; border-right: 1px solid var(--line); padding: 24px 16px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.side .brand { padding: 0 10px 18px; }
.side a { display: block; padding: 10px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; font-weight: bold; font-size: 14.5px; }
.side a:hover { background: #f3e9dd; }
.side a.active { background: var(--rose-soft); color: #8f3354; }
.side .spacer { flex: 1; }
.side .who { font-size: 12.5px; color: var(--muted); padding: 10px; word-break: break-all; }
main { padding: 28px 34px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 28px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: center; }
.toolbar input[type=search] { max-width: 260px; }
.toolbar select { width: auto; min-width: 150px; }
.toolbar .grow { flex: 1; }

/* cards + tables */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 26px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px 18px 16px; box-shadow: 0 14px 28px -24px rgba(80, 50, 70, .6); }
.card .k { font-size: 12px; font-weight: bold; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.card .v { font-family: var(--serif); font-size: 34px; margin-top: 4px; }
.card .n { font-size: 13px; color: var(--muted); }
.card.warn .v { color: var(--red); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.panel h2 { font-size: 18px; padding: 16px 18px 6px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fffaf4; }
td { padding: 12px 16px; border-bottom: 1px solid #f1e8dc; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #fffaf4; }
td .sub { display: block; font-size: 12.5px; color: var(--muted); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.empty { padding: 34px 18px; text-align: center; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.num { text-align: right; white-space: nowrap; }

.badge { display: inline-block; font-size: 11.5px; font-weight: bold; letter-spacing: .6px; text-transform: uppercase; padding: 4px 10px; border-radius: 999px; background: #eee; color: #555; }
.b-pending { background: var(--amber-soft); color: var(--amber); }
.b-confirmed, .b-processing, .b-client { background: var(--blue-soft); color: var(--blue); }
.b-cutting { background: var(--violet-soft); color: var(--violet); }
.b-stitching, .b-tailor { background: var(--rose-soft); color: #8f3354; }
.b-ready, .b-delivered, .b-active { background: var(--green-soft); color: var(--green); }
.b-failed, .b-disabled, .b-cancelled { background: var(--red-soft); color: var(--red); }
.b-admin { background: #2c2838; color: #fff; }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #d6cbbd; border-radius: 22px; transition: background .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::before { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(44, 40, 56, .45); display: grid; place-items: center; padding: 20px; z-index: 50; overflow-y: auto; }
.modal { width: 100%; max-width: 620px; background: var(--panel); border-radius: 20px; box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .5); max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 8px; }
.modal-head h2 { font-size: 22px; }
.modal-body { padding: 8px 22px 22px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; margin: 6px 0 18px; font-size: 14.5px; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { word-break: break-word; }
.mgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 8px 0 14px; }
.mgrid div { background: #fffaf4; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.mgrid b { display: block; font-size: 17px; }
.mgrid small { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; }
h3.sec { font-size: 15px; margin: 14px 0 6px; }
.hist { list-style: none; margin: 4px 0 14px; }
.hist li { display: flex; gap: 10px; align-items: center; padding: 4px 0; font-size: 14px; }
.hist time { color: var(--muted); font-size: 12.5px; }
.fab-row { display: grid; grid-template-columns: 1fr 120px 36px; gap: 8px; margin-bottom: 8px; }

#toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px); background: #2c2838; color: #fff; padding: 11px 20px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 80; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--red); }
.loading { padding: 40px; text-align: center; color: var(--muted); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; padding: 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side .brand { padding: 0 8px; }
  .side .spacer, .side .who { display: none; }
  main { padding: 20px 14px 50px; }
  .mgrid { grid-template-columns: repeat(2, 1fr); }
  .row2 { grid-template-columns: 1fr; }
}
