:root {
  --ink: #0E0D0B; --gold: #D4AF5A; --gold-hover: #EBCB7E; --gold-deep: #7A5F22;
  --bg: #F6F3EC; --card: #FFFFFF; --line: #DDD5C4; --line-soft: #EBE5D8; --field: #B8AE98;
  --text: #1C1913; --muted: #5E5646;
  --display: 'Cormorant Garamond', Georgia, serif; --body: 'Jost', system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--body); font-size: 16px; line-height: 1.5; }
button, input, select, textarea { font: inherit; }
a { color: var(--gold-deep); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
h1 { margin: 0; font-family: var(--display); font-weight: 600; font-size: 40px; line-height: 1.1; }
.muted { color: var(--muted); margin: 4px 0 0; }
.small { font-size: 14px; }
.strong { font-weight: 600; }
.logo { margin: 0; font-family: var(--display); font-size: 34px; font-weight: 600; color: var(--gold); line-height: 1; }
.sub { margin: 6px 0 0; font-size: 11px; letter-spacing: .28em; text-transform: uppercase; color: #CDBF9E; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 20px; border-radius: 4px; border: 1px solid transparent; font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-gold { background: var(--gold); color: #14110A; }
.btn-gold:hover { background: var(--gold-hover); }
.btn-dark { background: var(--text); color: #F3EEE4; }
.btn-line { background: transparent; color: var(--text); border-color: var(--field); }
.btn-dashed { margin-top: 16px; background: transparent; color: var(--text); border: 1px dashed #8C826E; }
.btn-small { min-height: 40px; padding: 0 14px; font-size: 14px; font-weight: 500; }
.link { background: none; border: 0; padding: 8px 0; color: var(--gold-deep); cursor: pointer; text-align: left; font-size: 15px; }
.link.light { color: var(--gold); }

label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=url], input[type=number], select, textarea {
  min-height: 44px; padding: 0 12px; border: 1px solid var(--field); border-radius: 4px; background: #fff; color: var(--text); font-size: 16px; font-weight: 400;
}
textarea { padding: 10px 12px; resize: vertical; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* auth */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--ink); }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border-radius: 6px; padding: 32px; }
.auth-card .sub { margin-bottom: 24px; color: var(--muted); }
.auth-card h1 { font-size: 32px; }
.msg { margin: 16px 0 0; font-size: 15px; color: var(--muted); min-height: 1.5em; }
.msg.err { color: #9B2C1F; }

/* layout */
.app { min-height: 100vh; display: flex; flex-wrap: wrap; }
.side { flex: 1 1 240px; background: var(--ink); color: #EDE6D6; padding: 28px 20px; display: flex; flex-direction: column; gap: 28px; }
.tabs { display: flex; flex-direction: column; gap: 4px; }
.tabs button { text-align: left; min-height: 44px; padding: 0 14px; border: 0; border-radius: 4px; background: transparent; color: #EDE6D6; font-size: 15px; cursor: pointer; }
.tabs button[aria-pressed="true"] { background: #2A251B; color: var(--gold); font-weight: 600; }
.side-foot { margin-top: auto; font-size: 14px; color: #A89F8C; display: flex; flex-direction: column; gap: 4px; }
.side-foot p { margin: 0; }
.side-foot .who { color: #EDE6D6; margin-bottom: 8px; word-break: break-all; }
.side-foot a { color: var(--gold); }
.main { flex: 999 1 560px; min-width: 0; padding: 36px 40px; }
@media (max-width: 640px) { .main { padding: 24px 16px; } h1 { font-size: 32px; } }
.head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; }
.card { margin-top: 24px; background: var(--card); border: 1px solid var(--line); border-radius: 6px; }
.narrow { max-width: 640px; padding: 24px; }
.toast { position: sticky; top: 12px; z-index: 5; margin: 0 0 16px; padding: 12px 16px; border-radius: 4px; background: #E3EEDF; color: #2C5427; font-weight: 600; }
.toast.err { background: #F6E1DC; color: #9B2C1F; }

/* piece form */
.form-grid { padding: 24px; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.drop { grid-row: span 3; border: 2px dashed var(--field); border-radius: 6px; min-height: 220px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 16px; }
.drop img { max-height: 200px; width: auto; border: 6px solid #1A1712; }
.drop input { font-size: 14px; max-width: 100%; }
.form-actions { grid-column: 1 / -1; display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; }

/* table */
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 15px; }
th { text-align: left; color: var(--muted); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; font-weight: 500; padding: 14px 12px; }
th:first-child, td:first-child { padding-left: 20px; }
th.r, td.r { text-align: right; padding-right: 20px; }
td { padding: 12px; border-top: 1px solid var(--line-soft); vertical-align: middle; }
.thumb { width: 44px; height: 54px; flex-shrink: 0; object-fit: cover; background: #3E382E; border: 4px solid #1A1712; }
.piece-cell { display: flex; align-items: center; gap: 14px; }
.piece-cell p { margin: 0; }
.ref { font-size: 13px; color: var(--muted); }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: #ECE7DD; color: var(--muted); }
.badge.on { background: #E3EEDF; color: #2C5427; }
.row-actions { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.danger { color: #9B2C1F; }
.pad { padding: 20px; margin: 0; }

/* services */
.svc-grid { margin-top: 24px; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.svc { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.svc .top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.svc .top input { flex: 1; font-family: var(--display); font-size: 22px; font-weight: 600; }
.svc .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.socials-fs { border: 0; border-top: 1px solid var(--line-soft); padding: 20px 0 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.socials-fs legend { font-weight: 600; padding: 0 0 12px; }
